为什么在安装virtualenv和virtualenvwrapper并添加
之后 export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /Users/<user>/Library/Enthought/Canopy_64bit/User/bin/virtualenvwrapper.sh
到我的.bash_profile
并且正在运行$ source ~/.bash_profile
,我遇到了:
/Library/Frameworks/Python.framework/Versions/7.3/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 virtualenv has been installed for
VIRTUALENVWRAPPER_PYTHON=/Library/Frameworks/Python.framework/Versions/Current/bin/python and that PATH is set properly.
我的.bash_profile看起来像:
# Setting PATH for EPD_free-7.3-2
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
export PATH
##
# Your previous /Users/<user>/.bash_profile file was backed up as /Users/<user>/.bash_profile.macports-saved_2012-11-06_at_11:39:22
##
# MacPorts Installer addition on 2012-11-06_at_11:39:22: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
# virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /Users/<user>/Library/Enthought/Canopy_64bit/User/bin/virtualenvwrapper.sh
# Added by Canopy installer on 2014-01-26
# VIRTUAL_ENV_DISABLE_PROMPT can be set to '' to make bashprompt show that Canopy is active, otherwise 1
VIRTUAL_ENV_DISABLE_PROMPT=1 source /Users/<user>/Library/Enthought/Canopy_64bit/User/bin/activate
答案 0 :(得分:2)
所以想通了。事实证明,当我为python安装EPD一段时间后,它添加了前几行:
# Setting PATH for EPD_free-7.3-2
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
export PATH
在我的.bash_profile
中。将我的python更新为Enthought Canopy后,我需要将这些行更改为:
# set path for current python
PATH="/Users/<user>/Library/Enthought/Canopy_64bit/User/bin:${PATH}"
export PATH
现在一切正常。然而事实证明,由于使用了Enthought,它不会在一天结束时起作用,它会向后移动venv,这是一个python 3标准,如here所述。