Well this will be a lengthy answer, so let's start :

Step 1: Install prerequisites : Upgrade any pre-installed packages:

$ sudo apt-get update
$ sudo apt-get upgrade

Install developer tools used to compile OpenCV 3.0:

$ sudo apt-get install build-essential cmake git pkg-config

Install libraries and packages used to read various image and videos formats from disk:

$ sudo apt-get install libjpeg8-dev libtiff5-dev libpng-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev

Install GTK so we can use OpenCV’s GUI features:

$ sudo apt-get install libgtk2.0-dev

Install packages that are used to optimize various functions inside OpenCV, such as matrix operations:

$ sudo apt-get install libatlas-base-dev gfortran

Step 2: Setup Python (Part 1)

Let’s download pip , a Python package manager, installed for Python 3:

$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python3 get-pip.py

Let’s use our fresh pip3 install to setup virtualenv and virtualenvwrapper :

$ sudo pip3 install virtualenv virtualenvwrapper

Now we can update our ~/.bashrc file (place at the bottom of the file):

# virtualenv and virtualenvwrapper
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
$ source ~/.bashrc
$ mkvirtualenv cv

Step 2: Setup Python (Part 2)

we’ll need to install the Python 3.4+ headers and development files:

$ sudo apt-get install python3.4-dev

OpenCV represents images as NumPy arrays, so we need to install NumPy into our cv virtual environment:

$ pip install numpy

Step 3: Build and install OpenCV 3.0 with Python 3.4+ bindings

$ cd ~
$ git clone https://github.com/opencv/opencv.git
$ cd opencv
$ git checkout 3.0.0
$ cd ~
$ git clone https://github.com/opencv/opencv_contrib.git
$ cd opencv_contrib
$ git checkout 3.0.0

Time to setup the build:

$ cd ~/opencv
$ mkdir build
$ cd build
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \

Let's start OpenCV compile process :

$ make -j4

Assuming OpenCV 3.0 compiled without error, you can now install it on your system:

$ sudo make install
$ sudo ldconfig

Step 4: Sym-link OpenCV 3.0

If you’ve reached this step, OpenCV 3.0 should now be installed in /usr/local/lib/python3.4/site-packages/.

Here, our OpenCV bindings are stored under the name cv2.cpython-34m.so

However, in order to use OpenCV 3.0 within our cv virtual environment, we first need to sym-link OpenCV into the site-packages directory of the cv environment, like this: (Be sure to take note of cv2.cpython-34m.so)

$ cd ~/.virtualenvs/cv/lib/python3.4/site-packages/
$ ln -s /usr/local/lib/python3.4/site-packages/cv2.cpython-34m.so cv2.so

Notice how I am changing the name from cv2.cpython-34m.so to cv2.so — this is so Python can import our OpenCV bindings using the name cv2 .

Step 5: Test out the OpenCV 3.0 and Python 3.4+ install

$ workon cv
$ python
>>> import cv2
>>> cv2.__version__

Hope that helps. Also, credit to Adrian Rosebrock on his post. It worked for me as a charm.

Ubuntu 16.04 安装opencv的各种方法(含opencv contrib扩展包安装 ...


2018年3月10日 ... 要在linux下安装opencv,有以下几种方法。具体操作如下:方法一(推荐):利用 pip安装opencv-python安装之前,如果你之前安装过旧版本 ...

Install OpenCV-Python in Ubuntu - OpenCV


Below steps are tested for Ubuntu 16.04 and 18.04 (both 64-bit). OpenCV-Python can be installed in Ubuntu in two ways: Install from pre-built binaries available ...



2016年5月27日 ... 1.下载opencv安装包首先先去opencv官网(http://opencv.org/downloads.html) 下载linux版本的opencv压缩包,此处下载的opencv3.1版本的。

Ubuntu python opencv安装配置- 简书


Ubuntu python opencv安装配置. 1.安装基本的开发包. sudo apt-get update upgrade sudo apt-get install build-essential cmake git pkg-config #加载图片工具  ...

How to Install OpenCV on Ubuntu 18.04 | Linuxize


Jan 12, 2020 ... Install OpenCV from the Ubuntu Repository # · Refresh the packages index and install the OpenCV package by typing: sudo apt update sudo apt ...

Ubuntu安装OpenCV-Python | 三_TensorFlowNews-CSDN博客


2019年11月18日 ... 在本教程中,我们将学习在Ubuntu System中设置OpenCV-Python。以下步骤针对 Ubuntu 16.04和18.04(均为64位)进行了测试。可以通过两种 ...

Ubuntu 安装python-opencv - Alex142857的个人空间- OSCHINA ...


2017年5月22日 ... install python-opencv sudo apt-get install python-opencv 测试是否安装成功在 terminal 中,输入python,进入python 编译环境,import cv2 回车 ...

pip install opencv-python


Jan 2, 2021 ... If you have previous/other manually installed (= not installed via pip ) version of OpenCV installed (e.g. cv2 module in the root of Python's ...

How to Install OpenCV on Ubuntu 20.04 | Linuxize


Jul 5, 2020 ... This article describes how to install OpenCV on Ubuntu 20.04. OpenCV is an open-source computer vision library with bindings for C++, Python ...

Ubuntu 18.04: How to install OpenCV - PyImageSearch


May 28, 2018 ... Step #0: Get comfortable — you'll be using Python 3.6. Let's familiarize ourselves with Python 3 on Ubuntu 18.04. To run Python 3 on Ubuntu ...

Ubuntu, how to install OpenCV for python3? - Stack Overflow


9 Answers · Step 1: Install prerequisites : · Step 2: Setup Python (Part 1) · Step 2: Setup Python (Part 2) · Step 3: Build and install OpenCV 3.0 with ...

pip install opencv - PyImageSearch


Sep 19, 2018 ... Option B: Install OpenCV on Ubuntu into a virtual environment with pip. There are huge benefits to Python virtual environments. The main ...

How do I install python-opencv? - Ask Ubuntu


Try sudo apt-get install python-opencv .

Install OpenCV3 on Ubuntu | Learn OpenCV


Jun 6, 2017 ... Step 1: Update packages · Step 2: Install OS libraries · Step 3: Install Python libraries · Step 4: Download OpenCV and OpenCV_contrib · Step 5: ...

How to install OpenCV on Ubuntu 20.04


Sep 10, 2020 ... Open means it is an open-source library with bindings for python, C++, and Java and supports different Operating Systems like Windows and ...