skip to Main Content

Have been spending many hours on getting this working with the newest python on Jetson, default it comes with Python 3.6.9 (Jetpack 4.6.4).
So I compiled Python 3.11 and registered it. It works.

NOTE: pip install opencv-python is NOT the solution I am looking for,
since that does not come with CUDA optimalisation.

jtop says: "It is installed"
PROBLEM: Python 3.11 import cv2 says: "No Module named cv2" while these did install according to "make install" results.

- Up-to-date: /usr/lib/python3.11/site-packages/cv2/__init__.py
-- Up-to-date: /usr/lib/python3.11/site-packages/cv2/load_config_py2.py
-- Up-to-date: /usr/lib/python3.11/site-packages/cv2/load_config_py3.py
-- Up-to-date: /usr/lib/python3.11/site-packages/cv2/config.py
-- Up-to-date: /usr/lib/python3.11/site-packages/cv2/misc/__init__.py
-- Up-to-date: /usr/lib/python3.11/site-packages/cv2/misc/version.py
-- Up-to-date: /usr/lib/python3.11/site-packages/cv2/mat_wrapper/__init__.py
-- Up-to-date: /usr/lib/python3.11/site-packages/cv2/utils/__init__.py
-- Up-to-date: /usr/lib/python3.11/site-packages/cv2/gapi/__init__.py
-- Up-to-date: /usr/lib/python3.11/site-packages/cv2/python-3.11/cv2.cpython-311-aarch64-linux-gnu.so
-- Up-to-date: /usr/lib/python3.11/site-packages/cv2/config-3.11.py

ERror we get…

Python 3.11.3 (tags/debian/3.11.3-1+bionic2-dirty:95ae635, Jun  5 2023, 15:54:34) [GCC 7.5.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>
ModuleNotFoundError: No module named 'cv2'

opencv cmake with the recommended options for Jetson says this (among others)

-   NVIDIA CUDA:                   YES (ver 10.2, CUFFT CUBLAS FAST_MATH)
--     NVIDIA GPU arch:             53
--     NVIDIA PTX archs:
-- 
--   cuDNN:                         YES (ver 8.2.1)
-- 
--   Python 3:
--     Interpreter:                 /usr/bin/python3.11 (ver 3.11.3)
--     Libraries:                   /usr/lib/aarch64-linux-gnu/libpython3.11.so (ver 3.11.3)
--     numpy:                       /usr/local/lib/python3.11/dist-packages/numpy/core/include (ver 1.25.0)
--     install path:                /usr/lib/python3.11/site-packages/cv2/python-3.11
-- 
--   Python (for build):            /usr/bin/python2.7

    

JTOP Output

2

Answers


  1. Chosen as BEST ANSWER

    The solution was that site-packages (some-how) is being ignored by python. When I changed the argument to dist-packages it works. cmake ...... (skip for brevity)

    -D PYTHON3_PACKAGES_PATH=/usr/local/lib/python3.11/dist-packages 
    

    now cv2 loads happily.


  2. My solution (after 2 hours!!!) was copying file cv2.pyd (from Python folder) to C:ProgramDataAnaconda3Libsite-packages

    Don’t know how it works. Sometimes you should not just follow official instructions but also do analogous things with both Python/pip and Anaconda/conda. I already met this while trying to install Tensorflow.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search