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:
- Flash Jetson Jetpack4.6 image from NVIDIA website.
- 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
- 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
- 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.
- Is there some way to have Python3.7 and also OpenCV4.1 and other tools that work perfectly fine with Python3.6?
- Am I doing something wrong in the process?
- 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 :)
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:
So for anyone who is facing similar issue, this is what I did to get through:
Flash Jetson Jetpack image from NVIDIA website.
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)
Follow the steps here: (section 2 applicable for me)
Installing TensorFlow for Jetson Platform :: NVIDIA Deep Learning Frameworks Documentation
Install ada-fruit libraries:
sudo pip3 install adafruit-circuitpython-servokit
On top of this, install the old version: (it will uninstall new versions automatically)
sudo pip3 install
If you skip step#4, you will not be able to install these packages in step#5. Weird but not for me to question.
- Now you will end up with working combination of:
- 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.