ImportError: 'encodings' という名前のモジュールがありません 質問する

ImportError: 'encodings' という名前のモジュールがありません 質問する

最近、Ubuntu を再インストールし、16.04 にアップグレードしましたが、Python が使用できません。

$ python manage.py runserver
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: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted

この時点ではPython自体は動作しません

$ 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: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted

この提案ももう機能しません:

unset PYTHONHOME
unset PYTHONPATH

1 つの方法で修正するたびに、同じ問題が再発します。いくつかの回答は一時的には解決しますが、完全には解決しません。Python と Python3 を何度も再インストールしました。ここから何ができるでしょうか?

ベストアンサー1

Python-3 の場合は、仮想環境ファイルを削除して、リセットしてみてください。

rm -rf venv
virtualenv -p /usr/bin/python3 venv/
source venv/bin/activate
pip install -r requirements.txt

https://wiki.ubuntu.com/XenialXerus/リリースノート#Python_3編集

おすすめ記事