jep
jep copied to clipboard
Unable to run jep: Fatal Python error: No module named 'encodings'
Hello, on mac os 10.14.2, i've installed python 3.6 from https://www.python.org/ftp/python/3.6.8/python-3.6.8-macosx10.9.pkg
Jep 3.8.2 is correctly installed:
> /Library/Frameworks/Python.framework/Versions/3.6/bin/pip3 install jep
Collecting jep
Installing collected packages: jep
Successfully installed jep-3.8.2
But when i run the jep:
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
What should i do ?
The first thing to do is see if the jep script is able to run, this script should be located at /Library/Frameworks/Python.framework/Versions/3.6/bin/jep and running it will give a python prompt similar to running python through the command line. If the script works you can check out the environment and command it is using to see how to set an environment for jep.
The simplest way to setup the environment is to set the PYTHON_HOME environmental variable, I don't use Mac OS so I''m not sure exactly which path to use but I would guess /Library/Frameworks/Python.framework/Versions/3.6/
.
Besides the jep script, does running python
from the command line work and if so can you import encodings? It sounds like the Python install may be incomplete somehow. It seems more like a Python problem than a Jep problem: https://stackoverflow.com/questions/38132755/importerror-no-module-named-encodings
It happened to me on a linux VM where i had the jep package installed under /usr/local/lib64/python3.6/site-packages. Python3.6 was installed under /usr/lib64. I made use of smart library loading and it threw an error during initialization when i set the python home that follows to the jep package.
@PradeepBadiger I think for your use case you would need to set a separate prefix and exec_prefix in PYTHONHOME as described in the python documention. Can you start an ordinary python3.6 interpreter on your linux vm and tell us what the values of sys.prefix and sys.exec_prefix are? Unfortunatly jep does not support that format of PYTHONHOME for finding libjep so you will need to use LD_LIBRARY_PATH or -Djava.library.path to find libjep. We should add support for the multipath PYTHONHOME to LibraryLocator
Target for 3.9.1 or 4.0.0, whichever comes first.
Hi @ndjensen - This is what i see.
[root@automation02 site-packages]# python3.6
Python 3.6.8 (default, Apr 25 2019, 21:02:35)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys;
>>> print(sys.prefix)
/usr
>>> print(sys.exec_prefix);
/usr
>>>
For now, I kind of work around this issue by installing the package in the actual python home location of /usr/lib64/python3.6 using below command.
python3.6 -m pip install --install-option="--prefix=/usr" jep
I retract my statement about targeting a fix for a release, as the idea that sys.prefix and sys.exec_prefix are different is now shown to be incorrect. At present we cannot recreate this problem and don't know how to fix it.
This may be irrelevant because the original ticket is at runtime on macOS and this error I'm linking to is at build time on Linux, but when building on travisCI with the Python 3.8-dev and Python 3.9-dev branches, we received that error. https://travis-ci.org/github/ninia/jep/jobs/690178200 https://travis-ci.org/github/ninia/jep/jobs/690185988
https://bugs.python.org/issue38236 added extra output to Python 3.8 and 3.9 when this occurs. Hopefully the extra output helps developers figure out what is going on.
Possibly related to #284
I got this on macOS with Python 3.7 and Jep 4.0 in a virtualenv. The fix was to not set PYTHONHOME which then caused the jep script to not see the virtualenv's site-packages directory.