我在使用PyQt / SIP方面遇到了一些麻烦。我想SIP被编译成64位,但Python在找到它时遇到了一些问题。
File "qtdemo.py", line 46, in import sip ImportError: dlopen(/Library/Python/2.6/site-packages/sip.so, 2): no suitable image found. Did find: /Library/Python/2.6/site-packages/sip.so: mach-o, but wrong architecture
答案 0 :(得分:18)
file
工具可用于识别可执行文件。
示例:
> file /Applications/TextEdit.app/Contents/MacOS/TextEdit
/Applications/TextEdit.app/Contents/MacOS/TextEdit: Mach-O universal binary with 2 architectures
/Applications/TextEdit.app/Contents/MacOS/TextEdit (for architecture x86_64): Mach-O 64-bit executable x86_64
/Applications/TextEdit.app/Contents/MacOS/TextEdit (for architecture i386): Mach-O executable i386
答案 1 :(得分:7)
要在您正在使用的Python实例中查找可用的体系结构:
$ file "$( "$(which python)" -c "import sys;print(sys.executable)" )"
/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
要查找Python当前是运行32位还是64位(10.6示例):
$ /usr/bin/python2.6 -c "import sys;print('%x'%sys.maxint)"
7fffffffffffffff
$ arch -x86_64 /usr/bin/python2.6 -c "import sys;print('%x'%sys.maxint)"
7fffffffffffffff
$ arch -i386 /usr/bin/python2.6 -c "import sys;print('%x'%sys.maxint)"
7fffffff
$ arch -ppc /usr/bin/python2.6 -c "import sys;print('%x'%sys.maxint)"
7fffffff
对于python3,将sys.maxsize
替换为sys.maxint
:
$ python3 -c "import sys;print('%x'%sys.maxsize)"
7fffffff
答案 2 :(得分:5)
lipo -info target/libexample-df07142d9bfd950a.a
input file target/libexample-df07142d9bfd950a.a is not a fat file
Non-fat file: target/libexample-df07142d9bfd950a.a is architecture: x86_64
或
lipo -info `which python`
Non-fat file: /usr/local/bin/python is architecture: x86_64
请勿使用file
。