I cloned opencv and opencv-contrib GitHub and build and install with cuda. Following are the python flags used.
In the opencv build, I can see cv2 module and python samples.
s1n7ax@s1n7ax:~/workspace/opencv/build$ tree python_loader samples
python_loader
├── cv2
│ ├── config.py
│ ├── _extra_py_code
│ │ └── __init__.py
│ ├── __init__.py
│ ├── load_config_py2.py
│ └── load_config_py3.py
└── setup.py
samples
...
├── python
│ ├── CMakeFiles
│ │ ├── CMakeDirectoryInformation.cmake
│ │ └── progress.marks
│ ├── cmake_install.cmake
│ ├── CTestTestfile.cmake
│ └── Makefile
...
When installing, it logs following message.
sudo make install
-- OpenCV Python: during development append to PYTHONPATH: /home/s1n7ax/workspace/opencv/build/python_loader
After the installation is completed, I added the path to and ran python.
export PYTHONPATH=/home/s1n7ax/workspace/opencv/build/python_loader && python3
However, I'm not able to import the cv2 module correctly.
Python 3.8.5 (default, May 27 2021, 13:30:53)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/s1n7ax/workspace/opencv/build/python_loader/cv2/__init__.py", line 117, in <module>
bootstrap()
File "/home/s1n7ax/workspace/opencv/build/python_loader/cv2/__init__.py", line 73, in bootstrap
load_first_config([
File "/home/s1n7ax/workspace/opencv/build/python_loader/cv2/__init__.py", line 70, in load_first_config
raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
ImportError: OpenCV loader: missing configuration file: ['config-3.8.py', 'config-3.py']. Check OpenCV installation.
How to fix this issue?

pip3 install --upgrade pyinstallerand in cmake, check your python3 Paths