2

I am struggling trying to install OpenCV 3.0.0 with Python3.4.3 and on a virtual env using pyenv. I am on Ubuntu 14.04.

I tried many things using various sources of information: http://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/ http://www.pyimagesearch.com/2015/06/29/install-opencv-3-0-and-python-3-4-on-osx/ Running OpenCV from a Python virtualenv How to install ipython qtconsole with pyenv (Python version 3.4.2)

The hard part for me was to link with the correct python from pyenv. I have 3.4.3 installed in pyenv with shared libraries (env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.4.3) and a virtualenv called "dev" with numpy installed and working.

My cmake command is as follow:

PREFIX_MAIN=`pyenv virtualenv-prefix`
PREFIX=`pyenv prefix`

cmake -D CMAKE_BUILD_TYPE=RELEASE \
  -D CMAKE_INSTALL_PREFIX="$PREFIX" \
  -D PYTHON3_LIBRARY="$PREFIX_MAIN"/lib/libpython3.4m.so \
  -D PYTHON3_INCLUDE_DIRS="$PREFIX_MAIN"/include/python3.4m \
  -D PYTHON3_EXECUTABLE="$PREFIX"/bin/python3.4 \
  -D PYTHON3_PACKAGES_PATH="$PREFIX"/lib/python3.4/site-packages/ \
  -D PYTHON3_NUMPY_INCLUDE_DIRS="$PREFIX"/lib/python3.4/site-packages/numpy/core/include \
  -D INSTALL_C_EXAMPLES=ON \
  -D INSTALL_PYTHON_EXAMPLES=ON \
  -D BUILD_EXAMPLES=ON \
  -D BUILD_opencv_python3=ON \
  -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..

But cmake still does not want to find the Python 3 Libraires (see cmake output below):

--   Python 2:
--     Interpreter:                 /home/group/.pyenv/shims/python2.7 (ver 2.7.6)
--
--   Python 3:
--     Interpreter:                 /home/group/.pyenv/versions/dev/bin/python3.4 (ver 3.4.3)
--     Libraries:                   NO
--     numpy:                       /home/group/.pyenv/versions/dev/lib/python3.4/site-packages/numpy/core/include (ver 1.10.0.post2)
--     packages path:               /home/group/.pyenv/versions/dev/lib/python3.4/site-packages
--
--   Python (for build):            /home/group/.pyenv/shims/python2.7

Also it seems it wants to use "/home/group/.pyenv/shims/python2.7" for build. I don't think it is the problem.

Investigating the cmake ouput I found the following:

-- Found PythonInterp: /home/group/.pyenv/versions/dev/bin/python3.4 (found suitable version "3.4.3", minimum required is "3.4")
-- Could NOT find PythonLibs: Found unsuitable version "3.4.0", but required is exact version "3.4.3" (found /home/group/.pyenv/versions/3.4.3/lib/libpython3.4m.so)

It seems libpython3.4m.so is version 3.4.0.. although I explicitly installed 3.4.3...Could this be the problem? How can I get the proper PythonLibs?

I have very little experience with these things and I am frankly lost here...

EDIT: I have tried to compile with python version 3.4.0 on my pyenv (env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.4.0) and it worked using the cmake commands above. Either opencv wants explicitly 3.4.0 either I don't understand how the shared library installed for 3.4.3 are actually seen as 3.4.0...

EDIT: Same problem with python 2.7.10 under pyenv, you should use 2.7.6...

-- Found PythonInterp: /home/group/.pyenv/versions/cv2/bin/python2.7 (found suitable version "2.7.10", minimum required is "2.7") 
-- Could NOT find PythonLibs: Found unsuitable version "2.7.6", but required is exact version "2.7.10" (found /home/group/.pyenv/versions/2.7.10/lib/libpython2.7.so)
Community
  • 1
  • 1
jgrizou
  • 21
  • 6

2 Answers2

0

I solved this problem by installing newer version of cmake. I'm using Ubuntu 14.04 and it seems, that the version of cmake shipped with this Ubuntu doesn't understand newer versions of python.

WestFlame
  • 435
  • 1
  • 7
  • 16
  • I upgraded cmake to 3.2.2 ( http://askubuntu.com/questions/610291/how-to-install-cmake-3-2-on-ubuntu-14-04 ) but I still get ```Could NOT find PythonLibs: Found unsuitable version "2.7.6", but required is exact version "2.7.11"``` when running cmake for opencv 3.1. Any other ideas? – visoft Feb 16 '16 at 13:25
0

Ok, solved for me too!

I have ubuntu 14.04 LTS, anaconda2, and I followed: http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu (without the contrib folder)

I constantly hit the "unsuitable version" problem. What solved for me is downgrading the python to exact version of my python2.7-dev, that is, 2.7.6.

Of course, in my anaconda environment:

conda install python=2.7.6

For now, I don't know how to upgrade the python2.7-dev library to 2.7.11 (and at this point I'm afarid to ask ;) )

Probably upgrading cmake to 3.2.2 also helped but it didn't solve the problem by itself.

Hope it helps!

p.s. put in comments how to easily and safely upgrade the python2.7-dev, if you know how.

visoft
  • 503
  • 5
  • 13