我刚刚安装了Canopy,并想测试它的虚拟环境集成。我发现当我停用虚拟环境时,我的系统Python会恢复到默认安装:
Mímisbrunnr:~ me$ which python
/Users/me/Library/Enthought/Canopy_64bit/User/bin/python
Mímisbrunnr:~ me$ venv ~/Projects/ProjectX/myvenv
Mímisbrunnr:~ me$ source ~/Projects/ProjectX/myvenv/bin/activate
(myvenv) Mímisbrunnr:~ me$ deactivate
Mímisbrunnr:~ me$ which python
/usr/bin/python
除了刚接触到Canopy之外,我对OS也很陌生。我怀疑这个问题与我的.bash_profile
和.profile
文件有关,但我似乎看不出如何让它们相互合作。这是我现在的.profile
# OS X looks in here first, but aliases in here won't work in xterm, screen, etc., so we port it over
echo 'source ~/.profile' >> ~/.bash_profile
# Added by Canopy installer on 2013-08-01
# 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/me/Library/Enthought/Canopy_64bit/User/bin/activate
这是我现在的.bash_profile
# set architecture flags to let compiler know it should assume 64 bits
export ARCHFLAGS="-arch x86_64"
# Added by Canopy installer on 2013-08-01
# 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/me/Library/Enthought/Canopy_64bit/User/bin/activate
# ensure user-installed binaries take precedence
#export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
# alias to start Canopy
alias canopy='open /Applications/Canopy.app'
# alias to combine cd & ls
function cdl () {
cd "$@" && ls
}
这些条目中有一些是我之前尝试安装IPython而没有Canopy的,所以我可能在Canopy的期望方面搞砸了。如何将这些文件配置为始终保持Canopy?
发布于 2013-08-02 03:16:56
您可以简单地在禁用~/.bash_profile
的venv以获取Canopy作为默认的Python之后,来源ProjectX。
默认情况下,activate
脚本在运行时是deactivate
的--查看~/Projects/ProjectX/myvenv/bin/activate
-- deactivate nondestructive
中的第38行。这一行删除了关于Canopy被设置为默认Python的所有旧信息。在获取文件之前,您可以注释掉这一行。但是,我认为在调用停用之后运行source ~/.bash_profile
是一项简单得多的工作。
https://stackoverflow.com/questions/18004808
复制相似问题