Bye Bye Moore


Raspberry Pi 3B+ とPython3な環境に OpenCV環境をつくる

今回は、OpenCVを Python3 on RasPi3B+ な環境に突っ込んでみます。


sudo apt update
sudo apt autoremove
sudo apt upgrade -y
sudo reboot
$ sudo apt-get install libhdf5-dev libhdf5-serial-dev libhdf5-dev
$ sudo apt-get install libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5
$ sudo apt-get install libatlas-base-dev
$ sudo apt-get install libjasper-dev
$ sudo apt-get install python3-opencv


opencv は諸事情により3系の最新版を導入。

$ pip3 install opencv-contrib-python==


$ python3 
Python 3.7.3 (default, Dec 20 2019, 18:57:59) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'cv' is not defined
>>> cv2.__version__


opencv-contrib-python · PyPI

Q: Pip fails with Could not find a version that satisfies the requirement ...?

A: Most likely the issue is related to too old pip and can be fixed by running pip install --upgrade pip. Note that the wheel (especially manylinux) format does not currently support properly ARM architecture so there are no packages for ARM based platforms in PyPI. However, opencv-python packages for Raspberry Pi can be found from


$ pip3 install opencv-contrib-python==
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes:,
ERROR: Could not find a version that satisfies the requirement opencv-contrib-python== (from versions:,,,,,,,,
ERROR: No matching distribution found for opencv-contrib-python==