I recently reinstalled ubuntu and did upgrade to 16.04 and cannot use python:
JavaScript
x
8
1
$ python manage.py runserver
2
Could not find platform independent libraries <prefix>
3
Could not find platform dependent libraries <exec_prefix>
4
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
5
Fatal Python error: Py_Initialize: Unable to get the locale encoding
6
ImportError: No module named 'encodings'
7
Aborted
8
At this point, python itself doesn’t work
JavaScript
1
8
1
$ python
2
Could not find platform independent libraries <prefix>
3
Could not find platform dependent libraries <exec_prefix>
4
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
5
Fatal Python error: Py_Initialize: Unable to get the locale encoding
6
ImportError: No module named 'encodings'
7
Aborted
8
Even this suggestion is no longer working:
JavaScript
1
3
1
unset PYTHONHOME
2
unset PYTHONPATH
3
Every every I fix it one way, it comes back again. Several answers help to fix it temporarily, but not for good. I have reinstalled python and python3 several times. What can I do from here?
Advertisement
Answer
For Python-3 try removing virtual environment files. And resetting it up.
JavaScript
1
5
1
rm -rf venv
2
virtualenv -p /usr/bin/python3 venv/
3
source venv/bin/activate
4
pip install -r requirements.txt
5
https://wiki.ubuntu.com/XenialXerus/ReleaseNotes#Python_3 edit fo