作法:Macports选择python
当我输入时:
port select --list python
结果如下:
Available versions for python:
none
python25 (active)
python25-apple
python26-apple
python27
python27-apple
我以为当我使用python时我会使用version 2.5
。相反,当我输入“ python”时,版本2.7似乎处于活动状态。如何将其更改为2.5版?
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
-
为什么会这样
MacPorts
/opt/local
默认将二进制文件安装到其中。Mac上还预装了python。当只是键入
python
开始时,它将启动不受MacPorts安装影响的预安装python版本。查看仅键入python时将执行的版本
which python
要启动mac端口版本,请使用
/opt/local/bin/python2.5
解
如果您希望始终使用MacPorts二进制文件,则可以更改路径,使其
/opt/local/bin
出现 在/use/local/bin
etc
之前 。/opt/local/bin
等由MacPorts添加到〜/ .tcshrc中。另外,请务必查看〜/ .profile和〜/
.bash_profile,因为它们是Mac上的默认设置。在端口中选择版本
首先键入
port select --list python
列出已安装的版本,然后例如sudo port select --set python python27
选择2.7。有关更多信息,请键入port help select
。