virtualenv
を使用して、DjangoプロジェクトをシステムのPythonバージョンから分離することが間違いありません。 virtualenv
は仮想環境(Djangoプロジェクト専用の専用Pythonバージョン)を作成するので、他の多くのものに使用されているシステムPythonバージョンのライブラリはインストールしないでください。 virtualenvwrapper
はvirtualenv
と簡単に作業できます。 pip install virtualenvwrapper
はあなたの友人です。ここでインストールする方法は次のとおりです。
# Install virtualenvwrapper with the system Python version
pip install virtualenvwrapper
# Then, add these lines to your .bashrc, with the appropriate path to Python 3
# You can find the path to Python 3 with "which python3"
# virtualenvwrapper.sh is typically in /usr/bin or /usr/local/bin
export VIRTUALENV_PYTHON=/usr/local/bin/python3.5
source /usr/bin/virtualenvwrapper.sh
その初期インストールした後、ここにvirtualenvwrapperで作業する方法は次のとおりです。
# Make a virtualenv
mkvirtualenv my_project
# You're now in the environment for your project
pip install Django
# When you need to activate the virtualenv to work on your project
workon my_project
# Show the virtualenvs you've created - I use one for each Django or Python project I create
lsvirtualenv
さらに多くのここ:https://virtualenvwrapper.readthedocs.io/en/latest/
幸運!
python3を使いたい場合は、 'pip'の代わりに' pip3'を使います。また、 'virtualenv'の使用を検討してください。 – jordanm
PYTHONPATHとvirtualenvの紹介については、http://djangodeployment.com/2016/11/01/virtualenv-demystified/ –