Install OpenCV for python3
<p>I have followed many manuals/tutorials how to install <a href="http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html?highlight=install%20linux" rel="nofollow">OpenCV</a>, but all seem to work for my python2.7 instead of python3.4 where I want it. I'm following <a href="http://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/" rel="nofollow">this</a> tutorial but without using virtualenv. When making the </p>

<pre><code>$cmake \                                                                                                                  
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D BUILD_EXAMPLES=ON \
-D PYTHON_EXECUTABLE=/usr/bin/python3.4 \
-D PYTHON_PACKAGES_PATHS=/usr/local/lib/python3.4/dist-packages/ \
-D PYTHON_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.4/dist-packages/numpy/core/include ..
</code></pre>

<p>comand it list both versions:</p>

<pre><code>--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 3.4.3)
--     Libraries:                   NO
--     numpy:                       /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.10.4)
--     packages path:               lib/python2.7/dist-packages
-- 
--   Python 3:
--     Interpreter:                 /usr/bin/python3.4 (ver 3.4.3)
--     Libraries:                   NO
--     numpy:                       /usr/local/lib/python3.4/dist-packages/numpy/core/include (ver 1.10.4)
--     packages path:               lib/python3.4/dist-packages
-- 
--   Python (for build):            /usr/bin/python2.7
</code></pre>

<p>But omits the python_executable flag and uses the python2.7 for building (I checked it worked on python2.7 after continuing with the installation). </p>

<p><strong>How can I make it that it uses python3.4 for the build?</strong></p>

<p>Things I tried:</p>

<p>When running this cmake:</p>

<pre><code>cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
-D PYTHON_EXECUTABLE=$(which python3) ..
</code></pre>

<p>It list correctly the libraries:</p>

<pre><code>--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 3.4.3)
--     Libraries:                   NO
--     numpy:                       /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.10.4)
--     packages path:               lib/python2.7/dist-packages
-- 
--   Python 3:
--     Interpreter:                 /usr/bin/python3.4 (ver 3.4.3)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.4m.so (ver 3.4.3)
--     numpy:                       /usr/local/lib/python3.4/dist-packages/numpy/core/include (ver 1.10.4)
--     packages path:               lib/python3.4/dist-packages
-- 
--   Python (for build):            /usr/bin/python2.7
</code></pre>

<p>But still list the python2.7 to build for.  </p>

<p>Related info:</p>

<pre><code>$whereis python3                                                                                                          
python3: /usr/bin/python3.4dm-config /usr/bin/python3.4m /usr/bin/python3.4m-config /usr/bin/python3.4-config /usr/bin/python3 /usr/bin/python3.4-dbg-config /usr/bin/python3.4 /usr/bin/python3.4-dbg /usr/bin/python3.4dm /etc/python3 /etc/python3.4 /usr/lib/python3.0 /usr/lib/python3.5 /usr/lib/python3 /usr/lib/python3.4 /usr/lib/python3.2 /usr/lib/python3.1 /usr/lib/python3.3 /usr/bin/X11/python3.4dm-config /usr/bin/X11/python3.4m /usr/bin/X11/python3.4m-config /usr/bin/X11/python3.4-config /usr/bin/X11/python3 /usr/bin/X11/python3.4-dbg-config /usr/bin/X11/python3.4 /usr/bin/X11/python3.4-dbg /usr/bin/X11/python3.4dm /usr/local/lib/python3.4 /usr/include/python3.4m /usr/include/python3.4 /usr/include/python3.4dm /usr/share/python3 /usr/share/man/man1/python3.1.gz
</code></pre>