我正在将在 windows 上开发的 python+opencv 应用程序移植到 mac。
在 Windows 上,我的 virtualenv 站点包中有 cv2.pyd,它运行良好。
我是 mac 新手,我不明白它应该可以工作。我没有找到任何用于 opencv python 绑定的二进制文件,似乎正确的方法是使用 macport。
macport 正在复制 opts/.../site-packages 中的 cv.py 和 cv2.so。
此时如何使用呢?
我尝试手动复制这两个文件,但出现错误
>>> import cv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/cv.py", line 1, in <module>
from cv2.cv import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/cv2.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/cv2.so: mach-o, but wrong architecture
怎么了?
更新:正如@Vortexfive 所问:
$ file /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/cv2.so
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/cv2.so: Mach-O 64-bit dynamically linked shared library x86_64
$ file /Library/Frameworks/Python.framework/Versions/2.6/bin/python
/Library/Frameworks/Python.framework/Versions/2.6/bin/python: Mach-O universal binary with 2 architectures
/Library/Frameworks/Python.framework/Versions/2.6/bin/python (for architecture ppc): Mach-O executable ppc
/Library/Frameworks/Python.framework/Versions/2.6/bin/python (for architecture i386): Mach-O executable i386
似乎有一个不匹配。如何解决?