Ask Your Question

Compile Python3 lib of OpenCV3.0

asked 2014-12-04 10:55:57 -0600

PierreBdR gravatar image

I am trying to compile the Python3 module for OpenCV using the latest version on git (Note: I also tried with the beta version and the problem is the same). Everything is done under Linux using Ubuntu 14.04.

It seems that, although CMake finds Python3, it gets ignored. More specifically, in the version_string file, I can see:

Python 2:
   Interpreter:                 /usr/bin/python2.7 (ver 2.7.6)
   Libraries:                   /usr/lib/x86_64-linux-gnu/ (ver 2.7.6)
   numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.8.2)
   packages path:               lib/python2.7/dist-packages
Python 3:
   Interpreter:                 /usr/bin/python3.4 (ver 3.4)
   Libraries:                   NO
   numpy:                       /usr/lib/python3/dist-packages/numpy/core/include (ver 1.8.2)
   packages path:               lib/python3.4/dist-packages

Although in CMakeCache.txt I have:

//Path to Python interpretor

//Python include dir

//Python include dir 2

//Path to Python library

//Path to Python debug

//Path to numpy headers

//Where to install the python packages.

Any idea what may be hapenning?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-05-06 20:46:29 -0600

Alprobit gravatar image

updated 2015-05-09 01:10:50 -0600

I had the same problem with opencv-3.0.0-beta and opencv-3.0.0-rc1.

Working solution for me with cmake-gui tool:

  1. the build directory MUST BE empty (otherwise I always got "Libraries: NO" for Python3 even through specify direct path to library)
  2. set source code directory and build directory paths
  3. add new entries (usgin "Add entry" button) that has to have non-default values (e.g., OPENCV_EXTRA_MODULES_PATH:PATH=../opencv_contrib/modules for extra modules)
  4. press configure only once
  5. if configuration satisfies your requirements (including Python 3 Libraries path correctness) then press generate otherwise go to step 1 (in the step 3 add necessary options).

After that run make -j6 and make install. After that I got working cv2 module for both python2 and python3.

edit flag offensive delete link more


you're right, thanks!!!!

craigstar gravatar imagecraigstar ( 2018-05-07 21:54:06 -0600 )edit

Can you tell us which new entries are needed?

lawrencem gravatar imagelawrencem ( 2019-08-28 10:45:11 -0600 )edit

Question Tools


Asked: 2014-12-04 10:55:57 -0600

Seen: 9,247 times

Last updated: May 09 '15