0

I cloned opencv and opencv-contrib GitHub and build and install with cuda. Following are the python flags used.

opencv python flags

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?

1
  • You could try ``` pip3 install --upgrade opencv-python``` and pip3 install --upgrade pyinstaller and in cmake, check your python3 Paths Commented Jun 6, 2021 at 12:15

1 Answer 1

3

After few tries, I realized following flags needs to be filled.

PYTHON3_EXECUTABLE=/usr/bin/python3
PYTHON3_INCLUDE_DIR=/usr/include/python3.8
PYTHON3_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.8.so
PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.8/dist-packades/numpy/core/include
PYTHON3_PACKAGES_PATH=/usr/local/lib/python3.8/dist-packades

To find these paths, I used find command.

I created a Youtube video so that I won't forget these later on

Sign up to request clarification or add additional context in comments.

1 Comment

So, are you saying that while building OpenCV, we should have ALL parameters configured before building? Or, after OpenCV is successfully built and installed, should ALL the parameters configured afterwards ???

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.