This post introduces how to install openCV in virtualenv on Ubuntu 16.04.
Make sure Python and Virtualenv is installed on your Ubuntu first.
Check my post about more details about how to setup python virtual environment and why it is better to install python libraries in Python virtual environment.
- Install OpenCV inside a virutalenv
activate your virtualenv first, then
if you only need main modules, run the following commands
$ pip3 install opencv-python
if you need both main and contrib modules (check extra modules listing from OpenCV documentation), run the following commands:
$ pip3 install opencv-contrib-python
- If you want to install OpenCV on your machine system-wide,
use the following instructions.
$ sudo apt-get install libopencv-dev python-opencv # if you only need main modules, run $ sudo pip3 install opencv-python # if you need both main and contrib modules (check extra modules listing from OpenCV documentation), run $ sudo pip3 install opencv-contrib-python