Install OpenCV for Python3 on Jetson TX2 without ubuntu host

I can’t seem to install opencv for python3 on my Tx2 developers kit. I believe it does work on python2 though.

nvidia@tegra-ubuntu:~$ python
Python 2.7.12 (default, Aug 22 2019, 16:36:40)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>

But when I try it on python3, it raises an error:

nvidia@tegra-ubuntu:~$ python3
Python 3.7.4 (default, sep 16 2019, 13:04:55)
[GCC 5.3.1 20160413] 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’ve tried building opencv from sources in different ways, but how do I make it work for python3 as well? I also tried it with pip but that again installs it for python2 and not python3.
I also tried pip3 but that does not work at all.

Furthermore, I do not have acces to JetPack, since I don’t have access to a physical Ubuntu host from which to flash the files.

Is there a way I can get libraries like opencv to work for python3? Thanks in advance!

You may need to enable it in openCV cmake and build it from source.

https://stackoverflow.com/questions/37070304/how-to-build-opencv-for-python3-when-both-python2-and-python3-are-installed

This thread should help.

Thanks for the answer.

I tried that yesterday, it still didn’t recognize cv2 in python3 unfornatunately.
Is there more information that I can provide to you that you need?

You have to check

  1. Whether there is indeed a cv2 library for your python3 that is built from source.
    You could check it before you tried to use the command “make”. CMake should show the python3 configuration info.

  2. After you build it, it may not be installed to your python3 dist-package folder and you may need to make a symlink for it.