[英]Import CV2: DLL load failed: The specified module could not be found while successful pip installation
I was working with Python 3.7 and OpenCV 4.2 in Pycharm IDE (Windows10).我在 Pycharm IDE (Windows10) 中使用 Python 3.7 和 OpenCV 4.2。 The system environment variables were changed by one of my co-workers by accident (we don't know what happened exactly).我的一位同事无意中更改了系统环境变量(我们不知道究竟发生了什么)。 Then I found that my code did not work with this error!:然后我发现我的代码没有出现这个错误!:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
Then I used this command:然后我使用了这个命令:
pip uninstall opencv-python
pip uninstall opencv-contrib-python
pip install opencv-python
All of them executed successfully, but when I write import cv2
the above error is appeared.所有这些都成功执行,但是当我编写import cv2
出现上述错误。 By the way, the system knows command Python
, it shows the right path to the python.exe
.顺便说一句,系统知道命令Python
,它显示了python.exe
的正确路径。 Moreover, commands like import numpy
works correctly!此外,像import numpy
这样的命令可以正常工作! How can I fix this problem?我该如何解决这个问题?
I found the answer!我找到了答案! There was an extra cv2.py
file in site-packages/cv2
path.在site-packages/cv2
路径中有一个额外的cv2.py
文件。 So, I removed it and the code worked所以,我删除了它并且代码有效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.