Có vẻ như các mô-đun mở rộng C đi kèm với wxPython 2.7 dmg here chỉ là 32 bit.
$ cd /usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.7/site-packages/wx-2.8-mac-unicode/wx
$ file *.so
_animate.so: Mach-O universal binary with 2 architectures
_animate.so (for architecture ppc): Mach-O bundle ppc
_animate.so (for architecture i386): Mach-O bundle i386
_aui.so: Mach-O universal binary with 2 architectures
_aui.so (for architecture ppc): Mach-O bundle ppc
_aui.so (for architecture i386): Mach-O bundle i386
...
Thật không may, platform.architecture()
không đưa ra một dấu hiệu cho thấy chính xác trong đó uốn cong một nhiều kiến trúc OS X Python đang chạy trong. Ví dụ, bằng cách sử dụng cài đặt python.org 3 vòm cho Python 2.7, platform.architecture()
luôn báo cáo 64 chút, ngay cả khi chạy ở chế độ 32-bit:
$ cd /Library/Frameworks/Python.framework/Versions/2.7
$ file python2.7
python2.7: Mach-O universal binary with 3 architectures
python2.7 (for architecture i386): Mach-O executable i386
python2.7 (for architecture ppc7400): Mach-O executable ppc
python2.7 (for architecture x86_64): Mach-O 64-bit executable x86_64
$ arch -x86_64 ./python2.7 -c 'import platform, sys; print "{0}, {1:x}".format(platform.architecture()[0], sys.maxint)'
64bit, 7fffffffffffffff
$ arch -i386 ./python2.7 -c 'import platform, sys; print "{0}, {1:x}".format(platform.architecture()[0], sys.maxint)'
64bit, 7fffffff
$ arch -ppc ./python2.7 -c 'import platform, sys; print "{0}, {1:x}".format(platform.architecture()[0], sys.maxint)'
64bit, 7fffffff
cách đáng tin cậy là để kiểm tra sys.maxint
cho Python 2 hoặc sys.maxsize
cho Python 3.
Bạn không nêu rõ trong câu hỏi của bạn như thế nào bạn gọi Python. Là nó thông qua một dòng shebang trong một tập lệnh? Nếu vậy, bạn có thể không chạy Python mà bạn nghĩ bạn đang sử dụng. Ngoài ra, bạn không chỉ ra Python 2.7 nào bạn đã cài đặt. Ví dụ, hiện tại có hai trình cài đặt cho Python 2.7 từ python.org: một trình hỗ trợ cả thực thi 32 và 64 bit, cái còn lại chỉ là 32-bit. Hãy thử như sau:
$ file $(python2.7 -c 'import sys;print(sys.executable)')
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: Mach-O universal binary with 3 architectures
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python (for architecture i386): Mach-O executable i386
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python (for architecture ppc7400): Mach-O executable ppc
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python (for architecture x86_64): Mach-O 64-bit executable x86_64
Vì vậy: nếu bạn có một phiên bản đa vòm của Python, bạn sẽ cần phải buộc nó để chạy ở chế độ 32-bit để tận dụng các wxPython tiền biên dịch.
Dường như có giải pháp cập nhật hơn cho vấn đề này [ở đây] (http://stackoverflow.com/questions/9205317/how-do-i-install-wxpython-on-mac-os- x). – senderle