20

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.

Community
  • 1
  • 1
Sabyasachi Mitra
  • 365
  • 1
  • 4
  • 12
  • 1
    did you mix up `PYTHONHOME` and `PYTHONPATH`? – Thomas Fenzl May 12 '13 at 20:41
  • 1
    I am not certain what exactly you're asking. I have used PYTHONHOME to pointo python libraries and PYTHONPATH to the interpretor. I am not if my understanding is correct. I'm a novice in python so your advise will be really helpful. – Sabyasachi Mitra May 12 '13 at 21:06
  • `PYTHONPATH` is the module search path, see also in the [documentation](http://docs.python.org/3/tutorial/modules.html#the-module-search-path). `PYTHONHOME` is used for the standard libraries, again, there's an explanation in the [docs](http://docs.python.org/3/using/cmdline.html#envvar-PYTHONHOME). Assuming you installed python3 under `/usr/local`, try that as `PYTHONHOME` – Thomas Fenzl May 12 '13 at 21:29
  • 1
    Brilliant! It worked like charm. But still I am getting the following error when the interpreter started: Traceback (most recent call last): File "/etc/pythonstart", line 5, in import atexit ImportError: No module named 'atexit'. Also, I am still not able to set python in eclipse: No output was in the standard output when trying to create the interpreter info. The error output contains:>>Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings' << Could you please help. – Sabyasachi Mitra May 13 '13 at 06:02
  • sorry, no idea what /etc/pythonstart is supposed to do. I think it either uses the wrong python interpreter or still has an invalid PYTHONHOME. Same thing with eclipse. – Thomas Fenzl May 13 '13 at 06:35
  • Hi Thomas- This may be a bad way of doing it but somehow it worked: I saw that the import atexit and import readline is giving the above mentioned error in /etc/pythonstart startup file. So I did a unset PYTHONSTARTUP and I at least I got a clean python3.3 start. But import atexit and import readline is still not working. Also, the eclipse is somehow not able to verify the changes I made to PYTHONHOME and PYTHONPATH as it's still complaining : 'The error output contains:>>Fatal Python error: Py_Initialize: import error 'encodings' I while adding /usr/local/bin/python3.3. Please help. – Sabyasachi Mitra May 13 '13 at 07:03
  • This is getting a bit long for comments, would you post a new question with the new problem description? – Thomas Fenzl May 13 '13 at 09:14

2 Answers2

2

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.

cdated
  • 1,753
  • 1
  • 14
  • 24
0

delete your virtual environment and create a new one and you will good to go