[英]Python + Django: Trouble with setting up mkvirtualenv on macOS
我正在使用 macOS (10.13.3) 並安裝了 Python v 3.6.4
我正在嘗試按照這篇 Mozilla 文章的說明進行操作: https : //developer.mozilla.org/en-US/docs/Learn/Server-side/Django/development_environment
我的流程:
1 which python
» /usr/local/bin/python
注意,一路上我做了一個符號鏈接ln -s /usr/local/bin/python3 /usr/local/bin/python
2 python3 -V
» Python 3.6.4
3 sudo -H pip3 install virtualenvwrapper
»
Requirement already satisfied: virtualenvwrapper in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requirement already satisfied: stevedore in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from virtualenvwrapper)
Requirement already satisfied: virtualenv in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from virtualenvwrapper)
Requirement already satisfied: virtualenv-clone in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from virtualenvwrapper)
Requirement already satisfied: pbr!=2.1.0,>=2.0.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from stevedore->virtualenvwrapper)
Requirement already satisfied: six>=1.10.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from stevedore->virtualenvwrapper)
4 nano .bash_profile
»添加以下內容: »
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
export WORKON_HOME=$HOME/.virtualenvs
# export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 # No impact
# export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3 # No impact
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python # No impact
# VIRTUALENVWRAPPER_PYTHON=`which python` # No impact
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh
5 source ~/.bash_profile
6 mkvirtualenv my_django_environment
»
Running virtualenv with interpreter /usr/local/bin/python
Using base prefix '/usr/local/bin/../../../Library/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/myuser/.virtualenvs/my_django_environment/bin/python
ERROR: The executable /Users/myuser/.virtualenvs/my_django_environment/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Library/Frameworks/Python.framework/Versions/3.6' (should be '/Users/myuser/.virtualenvs/my_django_environment')
ERROR: virtualenv is not compatible with this system or executable
7 面掌
我的 .bash_profile 文件的完整內容:
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh
我猜我的問題與以下有關,但我不知道這意味着什么,也不知道如何解決,有人可以幫我嗎?
ERROR: The executable /Users/myuser/.virtualenvs/my_django_environment/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Library/Frameworks/Python.framework/Versions/3.6' (should be '/Users/myuser/.virtualenvs/my_django_environment')
ERROR: virtualenv is not compatible with this system or executable
提前致謝!
我不完全確定,但我認為運行以下解決了我的問題:
pip3 install --upgrade virtualenv
很好,你設法解決了這個問題。
使用mkvirtualenv
一段時間后,我建議您嘗試Pipenv
如果您還沒有。
Pipenv
記錄您在 virtualenv 中使用的 python 版本,而virtualenvwrapper
(通過pip freeze
)沒有。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.