如何在 Mac 上的不同 Python 可执行文件之间快速切换? [英] How to quickly switch between the different Python executables on my Mac?
问题描述
谁能告诉我如何在 Mac 上的以下 Python 可执行文件之间快速切换?
Can anyone tell me how I can quickly switch between the below Python executables on my Mac?
我希望能够在一个特定的虚拟环境中规定使用 psiTurk 所需的 Enthought Canopy 可执行文件
I want to be able to stipulate in one particular virtual environment to use the Enthought Canopy executable which I need for psiTurk
- 计算机本机"/usr/local/bin/python
- 本地到虚拟环境"/Users/brendan/Dropbox/workspace/psiturktestfive
- Enthought Canopy"/Users/brendan/Library/Enthought/Canopy_64bit/User/bin/python
- ".bash_profile"/Library/Frameworks/Python.framework/Versions/2.7/bin/python
是否有一个简单的终端命令可以做到这一点?
Is there a simple terminal command to do it?
目前,如果我编辑我的 .bash_profile,我只能让我的机器使用 Enthought Canpy 版本,但是一旦我为项目激活新的虚拟环境,就会切换到本地 python 可执行文件的虚拟环境
Currently I am only able to make my machine use the Enthought Canpy version if I edit my .bash_profile but once I activate a new virtual environment for a project is switches to the virtual environments local python executable
一如既往地提供任何帮助,非常感谢.
Any help is as always, much appreciated.
以下错误是我尝试使用 virtualenv -p/Users/brendan/Library/Enthought/Canopy_64bit/User/bin/python canopy 时收到的错误
The below error is what i recieve when I try to use virtualenv -p /Users/brendan/Library/Enthought/Canopy_64bit/User/bin/python canopy
localhost:workspace brendan$ virtualenv -p /Users/brendan/Library/Enthought/Canopy_64bit/User/bin/python canopy
Running virtualenv with interpreter /Users/brendan/Library/Enthought/Canopy_64bit/User/bin/python
Using base prefix '/Applications/Canopy.app/appdata/canopy-1.4.1.1975.macosx-x86_64/Canopy.app/Contents'
New python executable in canopy/bin/python
dyld: Library not loaded: @rpath/Python
Referenced from: /Users/brendan/Dropbox/workspace/canopy/bin/python
Reason: image not found
ERROR: The executable canopy/bin/python is not functioning
ERROR: It thinks sys.prefix is u'/Users/brendan/Dropbox/workspace' (should be u'/Users/brendan/Dropbox/workspace/canopy')
ERROR: virtualenv is not compatible with this system or executable
localhost:workspace brendan$
推荐答案
您可以使用以下方法创建 virtualenv
:
You can create a virtualenv
by using:
virtualenv -p /Users/brendan/Library/Enthought/Canopy_64bit/User/bin/python canopy
然后做
source canopy/bin/activate
(如果您使用的是 Unix 并使用 Bash).
(if you are on Unix and use Bash).
Virtualenv 可以使用 pip install virtualenv
安装,或者按照 home 上的说明进行安装页面
Virtualenv can install with pip install virtualenv
, or follow instruction on the home page
这篇关于如何在 Mac 上的不同 Python 可执行文件之间快速切换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!