Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@haipnh
Created June 15, 2022 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haipnh/8f48c8c7a08c6620e1db61c54ab4fd32 to your computer and use it in GitHub Desktop.
Save haipnh/8f48c8c7a08c6620e1db61c54ab4fd32 to your computer and use it in GitHub Desktop.
Instruction to install OpenCV on Ubuntu 16.04 | NeuronBot
# Summary: We will create a virtual environment of Python-3.9 and install OpenCV-Python to it.
# 1. Add 3rd-party OpenCV-3.9 repository
sudo apt-key adv --refresh-keys --keyserver keyserver.ubuntu.com
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
# 2. Install packages
sudo apt-get install -y software-properties-common python3-pip python3.9 python3.9-dev python3.9-venv
# 3. Create virtual environment
cd ~
python3.9 -m venv venv
source ~/venv/bin/activate
pip install --upgrade pip==21.3.1
easy_install cpython
# 4. Build and install numpy from source
cd ~
git clone -b v1.22.4 https://github.com/numpy/numpy
cd ~/numpy
git submodule update --init
python3.9 setup.py install
# 5. Install OpenCV-Python to virtual environment
source ~/venv/bin/activate
cd ~
pip install opencv-python==3.4.18.65
# 6. Test OpenCV-Python
source ~/venv/bin/activate
python
import cv2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment