This is an error that I've seen in several different places but none of the listed solutions have worked for me.
I'm trying to use opencv but when I import the module I get the following error:
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
I have tried installing opencv from a pre-downloaded package, my computer has the current windows media pack and I jave run the module the depends without it listing any dependecy errors, I'm not sure what else to try at this point.
Edit: I have also tried installing opencv-contrib-python to no avail.
Let me know if you have any suggestions.
I had faced a similar issue and I solved it using:
pip install opencv-contrib-python
I updated from python 3.7.3 to python 3.7.6 and it fixed the problem. Worth a shot if you have the same issue.
Related
I currently have opencv-python 4.5.3.56 installed and running in Python 3.8. However, whenever I try to use the library, I get the error:
Traceback (most recent call last):
File "c:/Users/ryck5/Documents/FA2021/ECEG301/camerademo/color_detection.py", line 108, in <module>
dj.open_camera()
cap = opencv.VideoCapture(0)
AttributeError: module 'opencv' has no attribute 'VideoCapture'
I also tried print(opencv.__version__), but that gave me the same error, just with version instead of VideoCapture. I've tried uninstalling and reinstalling opencv countless times, using the opencv-contrib-python library instead, but nothing has worked. Any help would be much appreciated!
opencv library is used as cv2 namespace in python environment. Most probably you have installed python-opencv and using it.
Try:
import cv2 and then use cv2.VideoCapture().
Also, this is why opencv.__version__ is giving you error as there is no opencv object or library here. Try cv2.__version__.
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
I'm trying to import PyPDF2 and it won't work. I installed it using pip, then tried it with pip3, it is installed. When I try to import I get the error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyPDF2'
I'm using Python 3.7. I found a similar issue here, doesn't seem any of the answers worked and I tried them myself to the same results.
If anyone else runs into this problem try using sys.path to find the site-packages directory. I copied my PyPDF2 packages into my Python37 directory and now it works.
Not able to install any packages
I've tried VLC package from https://wiki.videolan.org/python_bindings
and got a traceback.
Now I am trying pygame module and this is what i get
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import pygame
File "C:\Users\Vineeth\AppData\Local\Programs\Python\Python36-32\lib\pygame\__init__.py", line 133, in <module>
from pygame.base import *
ImportError: DLL load failed: The specified module could not be found.
Please help i am pretty new to python
There are some release binaries for Python3.x, 64bit Windows at http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
I suggest you download it from that site and install it. It works for me. If you are using Windows ,it is a good way to install some packages,like lxml matplotlib.
Also you check out this question.
Hope this helps.
I tried to execute your statements and the imports worked fine for me. I have a 64bit Windows OS. And my python version Python 3.5.2 - 64bit.
Check if you have other Python versions, if you have removed them, make sure you did that right.
Ultimately I would just suggest you to do pip install pygame. The version compatibility will be handled by pip itself.
This is the error I get when trying to import numpy on opening python (2.7.8):
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
This is the path of my python binary /usr/local/bin/python
This is the path of pip /usr/local/bin/pip
Also, when I put in pip freeze I found the numpy package numpy==1.8.0rc1
I have looked at other relevant questions, but I'm not able to diagnose the cause. I'm guessing it might be some problem in PATHS. Where do I start?
As Akshat pointed out in the comments above, I had multiple versions of Python installed. This could have been the effect of using homebrew and/or macports in the past. I followed the steps detailed in Too many pythons on my Mac OS X Mountain Lion
and did a fresh install of Python 2.7.12 I was then able to reinstall pip and the packages subsequently.