如果您碰巧使用的是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,我建议你考虑一下。它节省了大量时间和手动配置和编译所有内容的心痛,并且有一个名为Porticus的出色 GUI 界面。当然,所有免费和开源!
ps永远不要替换或重命名原始系统二进制文件!正如 Ned Daily 的评论中所建议的那样:
“要么通过更改 PATH 环境变量中的搜索顺序来管理对预期 python 实例的访问,要么在必要时使用 /opt/local/bin/python2.6 之类的绝对路径”。