Py_Initialize: Unable to get the locale encoding in OpenSuse 12.3

Sabyasachi Mitra picture Sabyasachi Mitra · May 12, 2013 · Viewed 41.8k times · Source

I have downloaded Python3.3 and after unzipping it I issued ./configure, make and make altinstall. When I issued python3.3, the following message was shown:

Fatal Python error: Py_Initialize: Unable to get the locale encoding

ImportError: No module named 'encodings'

Aborted

I checked the Python environment variables and they seem to be okay.

In my .profile I inserted the following lines:

export PYTHONHOME=/usr/local/lib/python3.3/:/usr/local/lib/python3.3/lib/:/usr/local/lib/python3.3/lib/site-packages/
export PYTHONPATH=/usr/local/bin/
export PATH=$PYTHONPATH:$PATH

I then did source .profile, but Python won't start.

In Eclipse, after installing pydev, when I attempted to add the Python interpreter from /usr/local/bin, I got the following message:

No output was in the standard output when trying to create the interpreter info.
The error output contains:>>Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Traceback (most recent call last):
  File "/home/sabya/eclipse/plugins/org.python.pydev_2.7.3.2013031601/pysrc/interpreterInfo.py", line 52, in <module>
    import time
ImportError: No module named 'time'

I am at loss to understand what else I have to set in order for Python to work. I am running OpenSuSE 12.3.

Answer

cdated picture cdated · Jan 3, 2016

If you see this issue on Heroku make sure to create a runtime.txt file with "python-3.5.2" or whatever the latest runtime is from https://devcenter.heroku.com/articles/python-runtimes#supported-python-runtimes

This lets Heroku know to use the Python 3.x runtime.