The easiest way to install openCV is using pip. But before running that make sure you have following installed.

Python3+ - checkout how to install Python3

Pip3 - checkout how to install Pip3

Install OpenCV Required Packages

Run following command to install necessary packages for openCV.

sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

Pip Install OpenCV For Desktop Environments

Let us run following command to install openCV now.

pip3 install opencv-python
sudo pip3 install scikit-build
sudo pip3 install cmake
sudo pip3 install opencv-python

Note above open-cv python will install only main modules. To install both main and contrib modules, run following...

sudo pip3 install opencv-contrib-python

Pip install OpenCV For Server (headless) Environments

To install for headless environments that is where there is no GUI available. Do following...

To install main modules only...

sudo pip3 install opencv-python-headless

To install both main and contrib modules...

sudo pip3 install opencv-contrib-python-headless

Verify openCV Installation

To verify installation, invoke Python3 console and type following command...

import csv2

If you did't see any error, that means installation is successful.

Common Errors While Installing OpenCV

If you see following error...

ModuleNotFoundError: No module named 'skbuild'

do this...

Make sure Pip is latest - Update Pip

Then run following commands...

sudo pip3 install scikit-build
sudo pip3 install cmake
sudo pip3 install opencv-python