Canopy Express python不会持久存在

时间:2013-08-01 21:21:13

标签: python bash enthought .bash-profile python-venv

我刚刚安装了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?

1 个答案:

答案 0 :(得分:1)

在您停用ProjectX的venv后,您可以简单地获取~/.bash_profile来取回Canopy的Python作为默认Python。

默认情况下activate脚本deactivate运行时 - 查看~/Projects/ProjectX/myvenv/bin/activate - deactivate nondestructive中的第38行。此行删除有关将Canopy Python设置为默认Python的所有旧信息。在获取文件之前,您可以注释掉这一行。但是,我认为在调用deactivate之后运行source ~/.bash_profile是一个更简单的工作。