0

I've tried downloading opencv through pip, conda and downloading whl file from https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame , no luck so far.

I tried

pip install opencv-contrib-python ,
pip3 install opencv-contrib-python ,

pip install opencv-python, pip3 install opencv-python

All give same result, after successful installation, I get cv2 installed without an actual cv2.py file inside it, there is a folder CV2 inside site packages, which has looks like bellow:

enter image description here

and receive no module named cv2when asking to import cv2 on Spyder. When I use the ame command in the Python Shell, it imports with no issues and runs cv2.imread also with no issue, so am not quite sure if its a Python or a Spyder issue. I also used anaconda 3 conda install, there exist issues between h5py package and opencv package, have not been able to download. I use windows 10. Ive tried the method outlined here:

Cannot find module cv2 when using OpenCV

Ive installed, uninstalled and reinstalled python 3.7, Can anyone direct me on any other paths to take?

Community
  • 1
  • 1
El_1988
  • 339
  • 3
  • 13

1 Answers1

0

So I did the following to be able to run import cv2 from Spyder 3 (built in with Anaconda): Uninstall and Reinstall Anaconda 3 and adding it to the PATH. I then copied everything inside the cv2 folder in the python folder (shown in screenshot in original question) and added it to the Scripts Folder in the Anaconda Directory (where it has been downloaded).

My understanding is the issue arised from Spyder not sourcing the Python directory although the interpreter is set as python and the wd set as a subfolder of the python directory (whithin which the cv2 folder exists). Downloading directly from Conda didnt work due to compatibility issues between h5py and opencv. Check if you can import cv2 from Python shell directly, if so its a IDE issue - took me two days to figure it out.

El_1988
  • 339
  • 3
  • 13