【发布时间】:2015-10-06 15:34:37
【问题描述】:
我正在尝试启动并运行一个 django 项目,并且我正在运行 django,但是我在使用 python 的 virtualenv 时遇到了问题。
这是我的错误(在终端打开时显示)
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named virtualenvwrapper
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/Library/Frameworks/Python.framework/Versions/2.7/bin/python and that PATH is
set properly.
这是我的 .bash 个人资料的样子:
# Setting PATH for Python 3.4
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
export WORKON_HOME=$HOME/.virtualenvs
source /Library/Frameworks/Python.framework/Versions/3.4/bin/virtualenvwrapper.sh
export PIP_VIRTUALENV_BASE=$WORKON_HOME
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
我对命令行的东西和虚拟环境很陌生,所以我可能不知道我做错了一些“明显”的事情。谢谢。
【问题讨论】:
-
尝试评论
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}和下一行 -
同样的错误。不过还是谢谢。
-
您是否尝试过使用
mkvirtualenv --python /path/to/python3.4 venv_name指定要使用的python 版本? -
这是我一直在努力解决的问题之一,如何让 virtualenv 以不同版本的 python 为目标。一会儿我试试,谢谢!
-
无耻插件:如果 virtualenvwrapper 给你带来问题,也许你可以试试我自己的 Pew? github.com/berdario/pew
标签: python macos bash virtualenv virtualenvwrapper