missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS

Opencv 3.x (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)

ImportError: No module named numpy.distutils
-- Found PythonInterp: /home/satur/anaconda3/bin/python3 (found suitable version "3.6.4", minimum required is "3.4") 
-- Could NOT find PythonLibs (missing:  PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) (Required is exact version "3.6.4")
-- Looking for ccache - not found

原因:Linux下安装opencv-3.4.1cmake的时候没有找到python的PYTHON_INCLUDE_DIRSPYTHON_LIBRARIES位置
解决: 使用-DPYTHON_INCLUDE_DIR 来指明位置,如下所示

cmake .. \
-DPYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")  \
-DPYTHON_LIBRARY=$(python -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))")

如果是系统自带python2,但是使用都是anaconda的python3,只需要指明是python3 -c, 如下

cmake .. \
-DPYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")  \
-DPYTHON_LIBRARY=$(python3 -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))")

出处 Stackoverflow Cmake is not able to find Python-libraries

你可能感兴趣的:(Opencv)