2

Bit of a strange one here - I've installed opencv-python via pip install opencv-python, the installation was successful and can be seen via pip show opencv-python, but when trying to import it into a project the package can't be found. On further investigation there isn't actually an opencv (cv2?) folder in my site-packages, so I have no idea where it's retrieving the package info from. Has anyone ever come across this issue? I may be missing something totally obvious.

enter image description here

I've checked out a couple of similar questions but they seem to refer mainly to Linux; i.e. the package is in dist-packages rather than site-packages.

Links to questions:

Python-opencv import error, packages installed

Python package not found after installing package successfully

zbar missing from Python site-pakages after install

Edit - shifting some info from comments to question body:

pip install --force-reinstall --no-deps opencv-python reinstalls the package successfully

pip --version outputs the correct Python version and pip show -f opencv-python lists files correctly (even though they don't seem to exist when searched for in Windows explorer) - https://i.imgur.com/6PQnOS9.png

python -m site the sys.path directories are all correct - https://i.imgur.com/xKpyUtk.png

toti08
  • 2,342
  • 5
  • 22
  • 34
RyanHx
  • 381
  • 2
  • 9
  • Try running `pip install --force-reinstall --no-deps opencv-python` – hoefling Jul 11 '19 at 17:50
  • @hoefling thanks for the response. Sadly no luck on that command - it successfully reinstalls the package but it's still missing from the directory and can't be imported via `import cv2` – RyanHx Jul 11 '19 at 18:02
  • Can you run 1. `pip --version` to check the python version listed (must be 3.7) and 2. run `pip show -f opencv-python` and check the list of installed files, what does it show? – hoefling Jul 11 '19 at 18:20
  • @hoefling Screenshot - https://i.imgur.com/6PQnOS9.png. The python version checks out, and apparently the cv2 folder exists, but is missing when searched for in Windows explorer and Python projects. Very strange. – RyanHx Jul 11 '19 at 18:38
  • So what is the output if you now run `python -c "import cv2"` or `py -3.7 -c "import cv2"`? – hoefling Jul 11 '19 at 18:42
  • @hoefling on both commands I'm receiving `ModuleNotFoundError: No module named 'cv2'` – RyanHx Jul 11 '19 at 18:46
  • Hmm, can you also add the output of `python -m site`? – hoefling Jul 11 '19 at 18:49
  • @hoefling https://i.imgur.com/xKpyUtk.png - USER_BASE & USER_SITE labelled as non-existent, would this be the source of the issue? – RyanHx Jul 11 '19 at 18:54
  • No, don't worry - what's important is that `lib\site-packages` is included in `sys.path`, the rest is not relevant here. Don't have any more ideas tbh as everything looks good from the python side. – hoefling Jul 11 '19 at 19:13
  • @hoefling no worries, I appreciate your time. – RyanHx Jul 11 '19 at 19:43

0 Answers0