我刚刚安装了 Canopy Express 并想测试它的虚拟环境集成。我发现当我停用虚拟环境时,我的系统 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 X 也是新手。我怀疑这个问题与我的.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
}
其中一些条目来自我之前在没有 Canopy 的情况下安装 IPython 的尝试,所以我可能搞砸了 Canopy 的预期。如何配置这些文件以始终保留 Canopy Python?