1

As above, trying to install opencv-python.

Normally this would be a simple pip install opencv-python, but it doesn't seem to work. Instead, opencv install to the miniconda directory

/home/pi/miniconda3/lib/python3.5/site-packages

instead of global

/usr/lib/python3.7

Trying to add opencv-python in Thorny through the application fails. In the python program...

import sys
sys.path.append('/home/pi/miniconda3/lib/python3.5/site-packages')
import cv2

results in a

No module named 'cv2.cv2'

I've tried adding it to path also (export PYTHONPATH=/home/pi/miniconda3/lib/python3.5/site-packages:$PYTHONPATH) with no luck.

Community
  • 1
  • 1
Iorek
  • 571
  • 1
  • 13
  • 31

1 Answers1

1

Because pip is linked to your default Python and I think this default is your miniconda. A better approach is to call the Python version directly with pip. Additionally @Dave W. Smit mentioned that you should better install opencv-python-contrib to use the full OpenCV package (but don´t use both packages!).

$ python-3.7 -m pip install opencv-python-contrib

Or you can use the pip version (if pip is at least version 0.8)

$ pip-3.7 install opencv-python-contrib

Or with pip version 1.5+

$ pip3.7 install opencv-python-contrib
Kampi
  • 1,798
  • 18
  • 26
  • 1
    That, but I'd install `opencv-python-contrib`, which gets you some extra stuff. – Dave W. Smith Jul 26 '19 at 05:45
  • Thanks for the response. Even with the third point, I get a "ERROR: No matching distribution found". This is a pretty common response everytime I try and install it. – Iorek Jul 26 '19 at 10:03
  • I got to run to work, but it's possible this - https://stackoverflow.com/a/24664480/5050423 - is the problem – Iorek Jul 26 '19 at 10:14
  • Please try `sudo apt-get install python-opencv` instead or compile it from [source](https://gitlab.com/snippets/1721668). – Kampi Jul 26 '19 at 10:14
  • Like I say. Your miniconda is used as the default interpreter and not your Python 3.7. – Kampi Jul 26 '19 at 10:15