如果你碰巧正在使用MacPorts,就像指定告诉它不要编译 Universal 的变体一样简单,如下所示:
sudo port install python26 -universal
您可以使用以下命令查看可用的变体variants
命令:
% port variants python26
python26 has the variants:
darwin: Platform variant, selected automatically
no_tkinter: Disable Tkinter support, which will break IDLE
ucs4: Enable support for UCS4
universal: Build for multiple architectures
如您所见,默认情况下,在 10.6 上它构建了darwin
变体,仅构建 x86_64:
% cd /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/
% file python2.6
python2.6: Mach-O 64-bit executable x86_64
与通用的默认 python 二进制文件相比:
% file /usr/bin/python
/usr/bin/python: Mach-O universal binary with 3 architectures
/usr/bin/python (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/python (for architecture i386): Mach-O executable i386
/usr/bin/python (for architecture ppc7400): Mach-O executable ppc
如果您不使用 MacPorts,我建议您考虑一下。它节省了大量的时间和心痛,必须手动配置和编译所有内容,并且有一个出色的 GUI 界面,称为Porticus。当然,全部免费且开源!
p.s. Never替换或重命名原始系统二进制文件!正如 Ned Daily 评论中所建议的:
“要么管理对预期的访问
通过更改搜索的 python 实例
PATH 环境变量中的顺序
或者,如有必要,使用绝对路径
像/opt/local/bin/python2.6”。