JETSON Nano Python3.7 - OpenCV4.1 Installation Fail

Hello!

I’ve been trying for many days to get Python3.7 working with OpenCV4.1 but I’m unable to do so.

What I’ve done:

  1. Flash Jetson Jetpack4.6 image from NVIDIA website.
  2. Install Python3.7 and make it default Python3
$ sudo apt install python3.7-dev
$ sudo rm /usr/bin/python3
$ sudo ln -s /usr/bin/python3.7 /usr/bin/python3
  1. Install support packages for TensorFlow:
$ sudo apt-get update 
$ sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran 
  1. Build OpenCV using the script:
    GitHub - mdegans/nano_build_opencv: Build OpenCV on Nvidia Jetson Nano
    The problem starts here because I think this script doesn’t support Python3.7.
    After this script is run and when I execute Python3, trying to import cv2, I get this error:
    File , line1 in
    ModuleNotFoundError: No module named ‘cv2’

Why do I need Python3.7?
Because of the Adafruit libraries which are working only on Python3.7 and later.

Questions:

  1. Is there some way to have Python3.7 and also OpenCV4.1 and other tools that work perfectly fine with Python3.6?
  2. Am I doing something wrong in the process?
  3. Can I make adafruit libraries work with Python3.6? I’ve tried specifying an old version of adafruit on Python3.6, but then it installs some other supporting packages which are of new version, and then when I try to import for example (servokit library), it doesn’t work.

Please help me, I’ve been working on this for many days, and trying to figure this one out, instead of actually learning JETSON NANO :)

Thanks,
BR,
Waqas

Main cause of opencv failing to install for python3 is having opencv build set for python2 install (not sure why, but it is usual that it fails to install for both python2 and pyhton3).
You may try configuring and building/installing opencv such as here:

Hello

Thanks @Honey_Patouceul

So for anyone who is facing similar issue, this is what I did to get through:

  1. Flash Jetson Jetpack image from NVIDIA website.

  2. Do NOT install Python3.7. (You can install it if you want, its just that I’ve got a working setup with Python3.6 now)

  3. Follow the steps here: (section 2 applicable for me)
    Installing TensorFlow for Jetson Platform :: NVIDIA Deep Learning Frameworks Documentation

  4. Install ada-fruit libraries:
    sudo pip3 install adafruit-circuitpython-servokit

  5. On top of this, install the old version: (it will uninstall new versions automatically)
    sudo pip3 install
    adafruit-circuitpython-busdevice==5.1.2
    adafruit-circuitpython-motor==3.3.5
    adafruit-circuitpython-pca9685==3.4.1
    adafruit-circuitpython-register==1.9.8
    adafruit-circuitpython-servokit==1.3.8
    Adafruit-Blinka==6.11.1
    Adafruit-GPIO==1.0.3
    Adafruit-MotorHAT==1.4.0
    Adafruit-PlatformDetect==3.19.6
    Adafruit-PureIO==1.1.9
    Adafruit-SSD1306==1.6.2

If you skip step#4, you will not be able to install these packages in step#5. Weird but not for me to question.

  1. Now you will end up with working combination of:
  • python3.6
  • adafruit servo kit libraries
  • openCV 4.1
    Verified and working OK.

Tip: took alot of experiments, so if you’re in a similar situation I would recommend using VIRTUAL ENVIRONMENT, so you dont have to go through cycles of flashing/reflashing image!

Hope it helps someone else too…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.