所以我通过Macports安装了Python 3.3,使用端口安装python33
(使用OSX 10.8.2 ML)
一切正常(至少它没有在最后发出任何错误信息)
所以在此之后我想通过端口选择选择这个特定的python版本,并且首先希望现在拥有所有可用版本的列表:
port select –list python
现在这只给我一个3选项列表:
<code>Available versions for python:
None
python27 (active)
python33
</code>
在我安装python33之前,我还列出了python的苹果版本:
<code>Available versions for python:
none
python25-apple
python26-apple
python27 (active)
python27-apple
</code>
Apple版本仍然存在(位于:/System/Library/Frameworks/Python.framework/Versions),它们不再被列出.
有谁知道如何处理这个? (另外,当我在shell中使用python命令时,它仍然使用python27-apple版本.当我想要更改之前的版本时,发生了错误.但那将是另一个问题.)
编辑(24.10.2012):
与此同时,我发现了这个命令:
<code>port contents python_select </code>
这给出了:
<code>Port python_select contains:
/opt/local/etc/select/python/base
/opt/local/etc/select/python/none
</code>
除了此处列出的内容外,该文件夹还包含以下文件:
<code>drwxr-xr-x 8 admin 272 24 Okt 09:50 . drwxr-xr-x 5 admin 170 4 Okt 15:05 .. -rw-r--r-- 1 wheel 363 23 Okt 17:18 base lrwxr-xr-x 1 admin 8 23 Okt 18:05 current -> python27 -rw-r--r-- 1 wheel 26 23 Okt 17:18 none -rw-r--r-- 1 wheel 398 23 Okt 23:27 python27 -rw-r--r-- 1 wheel 384 23 Okt 17:21 python33 </code>
python27和33文件是一个简单的文本文件,具有以下相同的内容(版本号不同):
<code>bin/python2.7 bin/pythonw2.7 bin/python2.7-config bin/idle2.7 bin/pydoc2.7 bin/smtpd2.7.py bin/2to3-2.7 share/man/man1/python2.7.1 - /opt/local/Library/Frameworks/Python.framework/Versions/2.7 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Headers /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python </code>
但就是这样.我不知道我能用这些信息做些什么……
解决方法:
(Also, when I use the python command in the shell, it still uses the python27-apple version. When I wanted to change the version before, an error occurred. But that would be another question.)
这听起来像你的搜索路径不对.编辑?/ .bashrc并在接近结尾处输入:
<code>export PATH=/opt/local/bin:$PATH </code>
如果你想拥有这个系统范围,那么编辑/etc/bash.rc并将PATH定义放在那里.你想把它放在接近结尾的位置,因为bash资源有时会重新定义PATH(所以如果你把它放在开头,那么剩下的配置很可能会改变它).
无论如何,在下一次终端启动之后,命令python应该在/ opt / local / bin /中解析,而python可执行文件应该是一个符号链接到你选择的任何端口版本.
更新:您可以使用以下命令测试shell将选择哪个Python版本,具体取决于您的PATH设置:
<code>which python </code>
这应该打印
<code>/opt/local/bin/python </code>
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!