I want to use a static python interpreter to run on a rigidly managed server. So far I've built the interpreter, but I can only use it within the build directory.
If I try to copy it and use the copy, it stops working, and fails with the following error-
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
Current thread 0x0000000002812900 (most recent call first):
zsh: abort (core dumped) ./../python
I have seen this question, and using the fix suggested in the first answer gets rid of the prefix and exec_prefix problems, but not the 'Unable to get the locale encoding' problem. I can't really find a solution for this relevant to me.
This has nothing to do with virtualenv by the way, echo $PYTHONPATH
and echo $PYTHONHOME
both return an empty string when I try it outside of any virtualenvs. I can run the static binary just fine when it is in the build directory.
Here's an example of this-
~/Python-3.7.2$ ./python
Python 3.7.2 (default, Jan 26 2019, 19:14:39)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
~/Python-3.7.2$ cp python ..
~/Python-3.7.2$ ./../python
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
Current thread 0x0000000002812900 (most recent call first):
zsh: abort (core dumped) ./../python
~/Python-3.7.2$ export PYTHONHOME=/usr/local
~/Python-3.7.2$ ./../python
Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00000000011b1900 (most recent call first):
zsh: abort (core dumped) ./../python