我正在使用Python 3.6.0(Anaconda3)和jupyter笔记本开发windows 10。在本文的注释帮助下,我成功地安装并导入了OpenCV Python。
现在的问题是,如果我从安装opencv的同一个命令提示符导入opencv(ijport cv2),那么它导入时不会出现任何错误。
但是,如果我从另一个命令提示符导入opencv,则它会给出以下错误:
导入错误:加载DLL失败:找不到指定的模块。
我不能附上任何照片来显示这个,因为我的声誉是3。所以我在这里解释。
命令提示1:C:\Users\Prachi\AppData\Local\Programs\Python\Python36-
32\Anaconda3\Scripts>pip install opencv_python-3.2.0+contrib-cp36-cp36m-
win_amd64.whl
Processing C:\Users\Prachi\AppData\Local\Programs\Python\Python36-
32\Anaconda3\Scripts>pip install opencv_python-3.2.0+contrib-cp36-cp36m-
win_amd64.whl
Installing collected packages: opencv-python
Found existing installation: opencv-python-3.2.0.7
Uninstalling opencv-python-3.2.0.7:
Successfully uninstalled opencv-python-3.2.0.7
Successfully installed opencv-python-3.2.0+contrib
C:\Users\Prachi\AppData\Local\Programs\Python\Python36-
32\Anaconda3\Scripts>python
Python 3.2.0 |Anaconda4.3.1(64-bit)| (default, Dec 23 , 11:47:51) [MSC
v.1900 64-bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>import cv2
>>>
命令提示2:C:\Users\Prachi\AppData\Local\Programs\Python\Python36-
32\Anaconda3\Scripts>python
Python 3.2.0 |Anaconda4.3.1(64-bit)| (default, Dec 23 , 11:47:51) [MSC
v.1900 64-bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>import cv2
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Prachi\Anaconda3\lib\site-packages\cv2\__init__.py", line 7,
in
from . import cv2
ImportError: DLL load failed: The specified module could not be found.
>>>
这就是为什么,每当我打开新的命令提示符开始编码时,我必须再次安装opencv,然后使用它。
希望这个解释有助于理解这个问题。