如何:Macports 选择 python [英] How to: Macports select python
问题描述
当我输入时:
port select --list python
结果如下:
Available versions for python:
none
python25 (active)
python25-apple
python26-apple
python27
python27-apple
我认为当我使用 python 时,我会使用 2.5
版本.相反,当我输入python"时,2.7 版似乎处于活动状态.如何将其更改为 2.5 版?
I thought when I use python I would be using version 2.5
. Instead when I enter "python", version 2.7 seems to be active. How do I change that to version 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 版本.
There is also a preinstalled python on your Mac. When just typing python
to start, it will start the preinstalled python version not affected by MacPorts install.
只需输入python即可查看将执行的版本
To see what version will be executed when just typing python use
which python
启动mac端口版本使用
To start the mac ports version use
/opt/local/bin/python2.5
解决方案
如果您希望始终使用 MacPorts 二进制文件,您可以更改您的路径,以便 /opt/local/bin
出现在 before /use/local/bin
等
/opt/local/bin
等由 MacPorts 添加到 ~/.tcshrc 中.另外一定要查看 ~/.profile 和 ~/.bash_profile ,因为它们在 mac 上是默认的.
/opt/local/bin
etc. are added in ~/.tcshrc by MacPorts. Also be sure to look in ~/.profile and ~/.bash_profile as these are default on mac.
首先输入 port select --list python
来列出安装的版本,然后例如 sudo port select --set python python27
选择 2.7.欲了解更多信息,请输入端口帮助选择
.
First type port select --list python
to list installed version, then just for example sudo port select --set python python27
to select 2.7. For more information type port help select
.
这篇关于如何:Macports 选择 python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!