opencv with non default python executable

asked 2017-06-01 08:06:05 -0600

mahmood gravatar image

Hello

Following the manual of opencv-3.2, I used the following command

cmake -D CMAKE_BUILD_TYPE=Release \\
-D CMAKE_INSTALL_PREFIX=/opt/opencv-3.2.0/built/ \\
-D PYTHON2\(3\)_EXECUTABLE=/opt/python/bin/python3.3  \\
..

I expect that the compiler uses python 3.3, however, the output of the cmake command shows

--   Python 2:
--     Interpreter:                 /usr/bin/python2 (ver 2.6.6)
--
--   Python 3:
--     Interpreter:                 NO
--
--   Python (for build):            /usr/bin/python2

What did I miss in the command line?

edit retag flag offensive close merge delete

Comments

can you do without the \\ ? they look all suspicious.

then it's PYTHON3_EXECUTABLE (again, no slashes or braces)

also remember, that you'll need the python-dev headers & libs, + current numpy installed

berak gravatar imageberak ( 2017-06-01 08:44:01 -0600 )edit

This time, I see Interpreter: /usr/bin/python2 (ver 2.6.6) and Interpreter: /opt/python/bin/python3.3 (ver 3.3.6) and Python (for build): /usr/bin/python2. What does that mean?

mahmood gravatar imagemahmood ( 2017-06-02 06:00:54 -0600 )edit

It means that it is aware of the path for both Python 2 and Python 3 interpreters, and it is using Python 2 for the build process. I've successfully built the OpenCV bindings for the Python 3 interpreter when Python 2 is being used for the build process so you should be fine. If CMake is not auto detecting the other Python related build variables you may want to specify those as well. See step 4 in Installation in Linux

[optional] Building python. Set the following python parameters:
PYTHON2(3)_EXECUTABLE = <path to python>
PYTHON_INCLUDE_DIR = /usr/include/python<version>
PYTHON_INCLUDE_DIR2 = /usr/include/x86_64-linux-gnu/python<version>
PYTHON_LIBRARY = /usr/lib/x86_64-linux-gnu/libpython<version>.so
VideoCurious gravatar imageVideoCurious ( 2017-06-02 16:24:15 -0600 )edit