Iorek
Iorek

Reputation: 581

Installing opencv-python on raspberry pi 3, Raspbian Stretch

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.

Upvotes: 1

Views: 1159

Answers (1)

Kampi
Kampi

Reputation: 1891

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

Upvotes: 1

Related Questions