Search code examples
nvidiaopencvnvidia-jetsonnvidia-jetson-nanopython

Issue installing OpenCV 4.1.2 on Jetson Nano. import cv2, No module named 'cv2'


I installed OpenCV 4.1.2 from source with CUDA support. Had no issues. and created a symbolic link from OpenCV’s installation directory to my virtualenv

ln -s /usr/local/lib/python3.6/site-packages/cv2/python3.6/cv2.cpython-36m-aarch64-linux-gnu.so cv2.so

I am having an issue with import cv2

$ python
Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.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>
ModuleNotFoundError: No module named 'cv2'
>>> 

I checked site-packages directory and I can see cv2.so. I am obviously missing something. The main issue here in my view I am not able to link to my virtualenv, in fact I am able to check my installation and its working

 /usr/local/lib/python3.6/site-packages/cv2/python-3.6$ python
Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>

Solution

  • Issue solved a very very little mistake I changed the name from

    cv2.cpython-36m-aarch64-linux-gnu.so to cv2.so
    

    I realized it was an issue with one of the folders, this will do the magic:

    ln -s /usr/local/lib/python3.6/site-packages/cv2/python-3.6/cv2.so cv2.so
    

    notice its python-3.6 not python3.6 after cv2