我正在尝试在我的Ubuntu系统上安装OpenCV。我按照page的步骤进行了操作。我可以为C / C ++等运行演示。但是当我尝试运行python演示时,我得到一个ImportError: No module named cv2
以下是更多信息:
python --version
Python 2.7.8 :: Anaconda 2.1.0 (64-bit)
python -c 'import sys; print sys.path'
['', '/home/radar/anaconda/lib/python2.7/site-packages/pydy-0.2.1-py2.7.egg', '/home/radar', '/home/radar/opencv-2.4.9/modules/python/src2', '/home/radar/anaconda/lib/python27.zip', '/home/radar/anaconda/lib/python2.7', '/home/radar/anaconda/lib/python2.7/plat-linux2', '/home/radar/anaconda/lib/python2.7/lib-tk', '/home/radar/anaconda/lib/python2.7/lib-old', '/home/radar/anaconda/lib/python2.7/lib-dynload', '/home/radar/anaconda/lib/python2.7/site-packages', '/home/radar/anaconda/lib/python2.7/site-packages/PIL', '/home/radar/anaconda/lib/python2.7/site-packages/Sphinx-1.2.3-py2.7.egg', '/home/radar/anaconda/lib/python2.7/site-packages/runipy-0.1.1-py2.7.egg', '/home/radar/anaconda/lib/python2.7/site-packages/setuptools-5.8-py2.7.egg']
答案 0 :(得分:0)
您正在运行Anaconda Python发行版,但您需要使用本机python来访问openCV库。使用指定的路径运行Python,它应该可以工作:
/usr/bin/python
另请注意,要将openCV与虚拟环境一起使用,您需要手动将openCV运行对象(cv.py
,cv2.so
)复制到您要使用的环境中。 native python,默认路径为/usr/local/lib/python2.7/dist-packages/
。