-1

我正在使用 Mac OS X(雪豹)并尝试使用 python 绑定安装 opencv,但是当我尝试导入 cv 模块时出现以下错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cv.py", line 3, in <module>
    from cv2.cv import *
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cv2.so, 2): Symbol not found: _av_alloc_format_context
  Referenced from: /usr/local/lib/libopencv_highgui.2.4.dylib
  Expected in: /opt/local/lib/libavformat.dylib
 in /usr/local/lib/libopencv_highgui.2.4.dylib

我添加了以下路径:export PYTHONPATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages:$PYTHONPATH到我的~/.profile

有谁知道我该如何解决?

4

1 回答 1

1

从您的回溯中的路径来看,您似乎正在尝试将 MacPorts 安装的 Python 2.7 与您自己的opencv. 不要混搭。MacPorts 已经有一个带有 Python 绑定的opencv端口;用它。首先,删除opencv您安装到的/usr/local. 然后安装 MacPorts 版本:

sudo port selfupdate
sudo port -u install opencv +python27
于 2013-06-15T17:41:59.147 回答