本文介绍了当同时安装了python2和python3时,如何为python3构建opencv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试为python3构建opencv.但是,即使我手动为python3指定include和lib选项,cmake仍将python build选项设置为python2.7.11:
I was trying to build opencv for python3. However, cmake always sets python build option to be python2.7.11 even after I manually specified include and lib option for python3:
-- Python 2:
-- Interpreter: /home/ryu/anaconda2/bin/python2.7 (ver 2.7.11)
-- Python 3:
-- Interpreter: /usr/bin/python3 (ver 3.4.3)
-- Libraries: /usr/lib/x86_64-linux-gnu/libpython3.4m (ver 3.4.3)
-- numpy: /home/ryu/.local/lib/python3.4/site-packages/numpy/core/include (ver 1.11.0)
-- packages path: lib/python3.4/dist-packages
--
-- **Python (for build): /home/ryu/anaconda2/bin/python2.7**
我错过了一些cmake选项吗?
Did I miss some cmake option?
操作系统:Ubuntu 14,04
OS: Ubuntu 14,04
谢谢
推荐答案
您可以在cmake
调用过程中通过在Python可执行文件URI后面附加参数PYTHON_DEFAULT_EXECUTABLE
来覆盖要构建的python可执行文件.
You can override the python executable to build to by appending the argument PYTHON_DEFAULT_EXECUTABLE
with the python executable URI during the cmake
invokation.
cmake {...} -DPYTHON_DEFAULT_EXECUTABLE=$(which python3) ..
这篇关于当同时安装了python2和python3时,如何为python3构建opencv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!