{"id":1145,"hash":"cf7e07f7c71b81be39a34710ca4731119e05d035944bf1d344da0e91b63ce93c","pattern":"ImportError: No module named &#39;encodings&#39;","full_message":"I recently reinstalled ubuntu and did upgrade to 16.04 and cannot use python:\n\n$ python manage.py runserver\nCould not find platform independent libraries <prefix>\nCould not find platform dependent libraries <exec_prefix>\nConsider setting $PYTHONHOME to <prefix>[:<exec_prefix>]\nFatal Python error: Py_Initialize: Unable to get the locale encoding\nImportError: No module named 'encodings'\nAborted\n\nAt this point, python itself doesn't work\n\n$ python\nCould not find platform independent libraries <prefix>\nCould not find platform dependent libraries <exec_prefix>\nConsider setting $PYTHONHOME to <prefix>[:<exec_prefix>]\nFatal Python error: Py_Initialize: Unable to get the locale encoding\nImportError: No module named 'encodings'\nAborted\n\nEven this suggestion is no longer working:\n\nunset PYTHONHOME\nunset PYTHONPATH\n\nEvery 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?","ecosystem":"pypi","package_name":"python-3.x","package_version":null,"solution":"For Python-3 try removing virtual environment files. And resetting it up.\n\nrm -rf venv\nvirtualenv -p /usr/bin/python3 venv/\nsource venv/bin/activate\npip install -r requirements.txt\n\nhttps://wiki.ubuntu.com/XenialXerus/ReleaseNotes#Python_3\nedit fo","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/38132755/importerror-no-module-named-encodings","votes":170,"created_at":"2026-04-19T04:52:25.790135+00:00","updated_at":"2026-04-19T04:52:25.790135+00:00"}