简体   繁体   中英

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). 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. By the way, the system knows command Python , it shows the right path to the python.exe . Moreover, commands like import numpy works correctly! How can I fix this problem?

I found the answer! There was an extra cv2.py file in site-packages/cv2 path. So, I removed it and the code worked

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM