How can I run python for openCV on my Jetson?


I downloaded openCV from github and built it from source because I need a very specific release from openCV ie openCV2.4 .
I am now trying to run some opensource code. When trying to run one of their provided samples which is written in Python, I get “No module named cv2”. (Their code runs fine on my laptop)

I therefor tried sudo pip install opencv-python.
But this returns Could not find a version that satisfies the requirement opencv-python (from version: ) No match distribution for opencv-python

I also tried turning it the other way around ie sudo pip install python-opencv, but that returns exactly the same.

What can I do to solve the “No module named cv2” issue?



I also tried this straight in the command line

>>>>import cv2

which returns no module named cv2 and

>>>>import cv2

I am however totally able to compile my C++ code. Which means the installation was somehow successful, but something fails on the Python side.

related to my issue:

Had you configured opencv build with

# and/or

without error from configure ?

Furthermore, try import sys in python before import cv2.


thanks for your answer

I tried what you said and this is what it returned:

I nevertheless afterwards did: make -j5 and sudo make install, but the issue stayed the same


Those flags apparently don’t exist.
I used cmake-gui and didn’t see them

Sorry, for 2.4, you may use instead: -DBUILD_opencv_python=ON.
(you may check

I never use precompiled headers, and do not advise to use it.

When configuring with cmake-gui, if it enables WITH_OPENCL*, be sure to desactivate these.

Furthermore, you may do that before:

sudo apt-get install python-dev python-pip
sudo -H pip install numpy

I am affraid this didn’t work neither. I deactivated 3 things in cmake-gui: WITH_OPENCL, WITH_OPENCLAMDBLAS, WITH_OPENCLAMDFFT and activated: BUILD_opencv_python
This is the output I get when just doing cmake after what you told me:

yet, when doing:


import sys
import cv2

I get No module named cv2

What do you suggest?


I updated the link above

It is unclear if you’ve succeeded…

If not, have you tried with -DENABLE_PRECOMPILED_HEADERS=OFF ?

Note that you need to build and install opencv before testing with python.


Yes, your last comment solved my error. I made a mistake when doing what you suggested.

Glad to see you’ve moved on. Be aware anyway if you intend to use cuda that the configure output in the link of post #5 seems to have not activated cuda support. You may enable it with (for TX2):


Thanks for warning me that cuda isn’t activated, didn’t take that into consideration yet.

Although I got past my initial error, I do however still get an error like this one when trying to run my openCV code:

imshow: The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or
Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and
pkg-config, then re-run cmake or configure script

I installed libgtk2.0-dev and pkg-config, selected WITH_QT=ON in the cmake-gui and installed libqt4-dev, but the error persisted.

I followed this advice: python - OpenCV error: the function is not implemented - Stack Overflow

So I guess there still is something wrong in the installation somehow.

GTK is different from Qt.
You may leave WITH_QT=OFF unless you need QT backend support.

Try reconfiguring with cmake-gui until it gives no red message (and no red new/modified variable), regenerate, rebuild and re-install. (You may try make clean in your build directory, or better to delete everything and restart from scratch, it will detect your new installation, just be sure to desactivate opencl and configure everything the way you want after the first configure).

One more thing to check is: do you still have opencv4tegra installed ? :

ls /usr/lib/libopencv*

How is set CMAKE_INSTALL_PREFIX ? It is the path where opencv will be installed.

removed the opencv directory, unzipped it again. Did all the steps you mentionned. But still got all those red messages. I think anything related to “haar” has to do with openCV contrib, so I deactivated BUILD_opencv_contrib, but those red messages stayed:

ls /usr/lib/libopencv* doesn t show anything related to opencv for tegra. ls /usr/lib/open* shows:
openmpi and openssh in my case, nothing else.

CMAKE_INSTALL_PREFIX is set to /usr/local, while my sources and the build folder are in ~/Downloads .

Although those messages stayed, this once again solved my issue. Thank you very much!

Do you have precompiled headers activated ? If yes, I’d suggest to disable these and reconfigure/rebuild/reinstall.