我已经成功安装了OpenCV,但是当我尝试将其导入Python时,出现以下错误。
在Python 2.7中,我得到了
$ echo $EDITOR
vim
在Python 3.6中,出现此错误
[imukunya@li165-244 site-packages]$ python
Python 2.7.5 (default, Oct 30 2018, 23:45:53)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: numpy.core.multiarray failed to import
我已经尝试使用[imukunya@li165-244 site-packages]$ python3.6
Python 3.6.5 (default, Apr 10 2018, 17:08:37)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define module export function (PyInit_cv2)
答案 0 :(得分:0)
请尝试执行以下命令。然后,请验证您的代码是否正常工作。
python -m pip install opencv-contrib-python