MacPorts 选择错误的 Python 问题
我之前在 /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
这个地方安装了Python。然后在更新到Lion系统后,我又在 /System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
这个地方重新安装了一次。但是,当我通过MacPorts安装任何Python包时,安装总是失败,并显示以下信息:
CPATH='/opt/local/include' MACOSX_DEPLOYMENT_TARGET='10.7' LIBRARY_PATH='/opt/local/lib' F90FLAGS='-m64' CC_PRINT_OPTIONS_FILE='/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_mercurial/mercurial/work/.CC_PRINT_OPTIONS' LDFLAGS='-arch x86_64' FCFLAGS='-m64' OBJCFLAGS='-arch x86_64' FFLAGS='-m64' CC_PRINT_OPTIONS='YES'
:debug:build Assembled command: 'cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_mercurial/mercurial/work/mercurial-1.9" && /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 setup.py --no-user-cfg build'
:debug:build Executing command line: cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_mercurial/mercurial/work/mercurial-1.9" && /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 setup.py --no-user-cfg build
:info:build sh: /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6: No such file or directory
:info:build shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_mercurial/mercurial/work/mercurial-1.9" && /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 setup.py --no-user-cfg build " returned error 127
:error:build Target org.macports.build returned: shell command failed (see log for details)
:debug:build Backtrace: shell command failed (see log for details)
while executing
"command_exec build"
(procedure "portbuild::build_main" line 8)
invoked from within
"$procedure $targetname"
:info:build Warning: the following items did not execute (for mercurial): org.macports.activate org.macports.build org.macports.destroot org.macports.install
:notice:build Log for mercurial is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_mercurial/mercurial/main.log
这个问题发生在我安装mercurial的时候。我尝试把默认的Python设置为活动版本,但没有用。
我该如何让MacPorts使用我想要的Python版本呢?我应该能够告诉它使用哪个版本和哪个位置。
2 个回答
我发现用virtualenv来编写Python程序是最好的选择。这样一来,就不会搞不清楚依赖关系在哪里了,而且用pip或easy_install安装软件包也非常简单。如果你在网上搜索一下,会发现很多有用的博客文章,教你如何设置和有效使用它。
你说你在 /System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
重新安装了 Python 2.6,这是什么意思呢?这个位置是苹果自带的 Python 2.6 在 Lion 系统中的存放地点。其实在这个框架里,还有苹果自带的 Python 2.7 和 2.5 版本。千万不要修改或删除 /System/Library
里的任何东西!MacPorts 版本还是像以前一样安装在 /opt/local/
里。
自从升级到 Lion 之后,你有没有:
从 Mac 应用商店下载 Xcode 4.1 的安装包,然后在
/Applications
里运行它的安装程序?更新你的 MacPorts 端口设置,以支持 Lion 的最新更新吗?
$ sudo port selfupdate $ sudo port -u upgrade outdated
你有在使用 MacPorts 的 mercurial 端口吗?
$ sudo port install mercurial
你有没有修改你的 PATH 环境变量,把
/opt/local/bin
加进去,或者你是直接使用 MacPorts Python 的绝对路径:/opt/local/bin/python2.6
?