To install OpenCV from the Ubuntu 18.04 repositories, follow these steps:

  1. Refresh the packages index and install the OpenCV package by typing:

    sudo apt updatesudo apt install python3-opencv

    The command above will install all packages necessary to run OpenCV.

  2. To verify the installation, import the cv2 module and print the OpenCV version:

    python3 -c "import cv2; print(cv2.__version__)"
    Copy
    3.2.0

The default Python version in Ubuntu 18.04 LTS is version 3.6. If you want to install OpenCV with python 2 bindings install the python-opencv package.