1

I am trying to get opencv to work with Python3.5 on Ubuntu 16.04

I have followed the steps in the answer to this: How to install OpenCV 3.1 for Python 3.5 On Ubuntu 16.04 LTS?

and also the link in it. I did have to install some other dependencies too.

My first issue is that cmake keeps finding Python3.4 not Python3.5.

--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.11)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.11+)
--     numpy:                       /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.11.1)
--     packages path:               lib/python2.7/dist-packages
-- 
--   Python 3:
--     Interpreter:                 /usr/bin/python3.4 (ver 3.4)
-- 

There are some other missing dependencies too mentioned. I don't know how essential they are. e.g. Matlab:

--   Matlab:                        Matlab not found or implicitly disabled

also gtk+-3.0 although I thought I had installed that:

-- Checking for module 'gtk+-3.0'
--   No package 'gtk+-3.0' found

and a couple of others:

-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file

-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- Checking for module 'libavresample'
--   No package 'libavresample' found

I did a grep / sed command to modify python3.4 to 3.5 and tried make and make install but it's still not there.

CashCow
  • 231
  • 1
  • 2
  • 9
  • Usually these sorts of issues are the result of confusion between the runtime packages (e.g. libgtk-3-0, python3.5 etc.) and the corresponding development header/library packages (libgtk-3-dev, python3.5-dev etc.) - the latter packages are what you need for building software from source. – steeldriver Aug 03 '16 at 19:08

1 Answers1

0

A detailed answer to all of these will take too much space and effort, plus additional information about each of these packages.

But in general, the strategy is:

  1. If the package is not found first make sure you have it. E.g. check with dpkg -l "*libXXX*". In case of python, check which python is picked up by the system with which python3 command. It doesn't mean the same one will be found by cmake (cmake can use different order of search directories), but it is likely.

  2. If you have it, but it is not in a standard path, just not found or different version is found, you usually need to

    a) set some environment variables

    or b) modify the findXXX.cmake scripts that you find in "cmake" folder of OpenCV source

    or c) modify the OpenCV CMakeLists.txt file to set the needed Cmake-variables (which findXXX normally sets) manually.

  3. The things above are easier to do with cmake-qt-gui (install it if you don't have it). Then when it finds wrong python, you can just enter the path to the right one using the GUI.

  4. Matlab/VTK not found in not a disaster. There are many optional packages that you can built with. Unless cmake actually says, that it cannot build the OpenCV modules you need without it or unless you really want to use this package (e.g. for performance reasons), you don't need to do anything. Which OpenCV modules require which packages and what are the advantages of using certain optional packages you need to find out individually for each package. But if you want to build with Matlab or VTK, you need to make sure cmake will find it. So read the points 1.,2., 3.

Noidea
  • 101