How to properly install and configure OpenCV in an environment?

This is my scenario:

I need to configure it with the following libraries:

matplotlib == 3.1.2
numpy == 1.18.0
scipy == 1.1.0
scikit-learn 0.21.3
opencv == 4.1.0

(I also need opencv-contrib).

So far I’ve done the following:

Install pip:
sudo apt install python3-pip

Use virtual environments:
sudo apt install -y python3-venv
python3 -m venv ~ / python-environments / OpenCV
source ~ / python-environments / OpenCV / bin / activate

Install wheel:
pip3 install wheel

Setting up Jupyter Notebook:
pip3 install jupyter

Install all dependencies.

When I open Jupyter Notebook I can run all dependencies mentioned above, now I would like to install opencv and opencv-contrib within this environment of mine and that when opening Jupyter Notebook I managed to run it too.

(my script to build any recent version):

(AastaNV’s Script to build 4.1.1)

There is no pre-built package with CUDA enables. You must use a build script to install this.

Also please be aware mosy OpenCV code does not use the GPU at all, and many tests fail for the CUDA related functins on Tegra. YMMV. Nvidia provides more performant alternatives for most things.