Import error while importing cv2 in Spyder(Python 3.6)
Solution 1
Go to https://pypi.org/project/opencv-python/
and copy pip install opencv-python
Now open C:\Users\XYZ\...\WinPython
folder and open WinPython command prompt which is inside the folder WinPython
Here paste pip install opencv-python
and press enter
Next type pip install opencv-contrib-python
and press enter.
Voila! Your opencv is installed. Open your Python 3.6.5 Shell and type
>>> import cv2
>>>
It is successfully installed!
Solution 2
Open Anaconda prompt then type the command
pip install opencv-python
and this worked fine for me for anaconda 3.
Related videos on Youtube
Saradamani
I am a data scientist by profession but I am open to all ideas, belief systems and theories.I love programming ,Mathematics especially Number Theory, Probability Theory, Graph Theory etc. , teaching professionals and students alongside my regular job.
Updated on January 11, 2021Comments
-
Saradamani over 3 years
I have already installed opencv 3.0.0 in windows os. I have run the application and have successfully installed it in
C:\
drive and have also copied thecv2.pyd
file inC:\Python27\Lib\site-packages
as I saw in several tutorial videos and in my Python 2.7.5 Shell i.e IDLE when I type>>>import cv2
>>>
It shows it has been safely installed and running.
Now I am using Spyder 3.6 as this is the latest version available for my Machine Learning programs but here if I follow the above steps it shows the error
ModuleNotFoundError: No module named 'cv2'
Now I copy the same
cv2.pyd
file in the pathC:\Users\Chirantan\Documents\WinPython\python-3.6.5.amd64\Lib\site-packages
But the error now is
File "ipython-input-36-c8ec22b3e787", line 1, in
import cv2
ImportError: DLL load failed: %1 is not a valid Win32 application.
I have 2 questions do I have to install a separate opencv for Spyder 3.6 and install it in
C:\Users\Chirantan\Documents\WinPython
and copy the
cv2.pyd
file inC:\Users\Chirantan\Documents\WinPython\python-3.6.5.amd64\Lib\site-packages
In this case it shows an error
File "ipython-input-36-c8ec22b3e787 ", line 1, in
import cv2
ImportError: DLL load failed: %1 is not a valid Win32 application.
How do I solve this problem?
What should be the correct version of opencv to be installed for Spyder 3.6 and where should be the location where it should be saved and ehere should I put the
cv2.pyd
file?Any Help Is Appreciated.
No I want to know what should be the correct version of opencv to be installed for Python 3.6 and provided I have an updated numpy that comes with the spyder package i.e winpython package, where should I install and save the correct file opencv in the winpython folder?
-
ScottMcC almost 6 years
-
-
clubby789 almost 5 yearsThey're not using Anaconda