CMake配置OpenCV时,显示错误:find_host_package(PythonInterp 2.7)' found wrong Python version
问题描述:
CMake配置OpenCV时,显示错误:find_host_package(PythonInterp 2.7)' found wrong Python version,具体提示如下:
Found PythonInterp: C:/Users/LiuBing/AppData/Local/Programs/Python/Python38/python.exe (found suitable version "3.8.2", minimum required is "2.7")
CMake Warning at cmake/OpenCVDetectPython.cmake:81 (message):
CMake's 'find_host_package(PythonInterp 2.7)' found wrong Python version:
PYTHON_EXECUTABLE=C:/Users/LiuBing/AppData/Local/Programs/Python/Python38/python.exe
PYTHON_VERSION_STRING=3.8.2
Consider providing the 'PYTHON2_EXECUTABLE' variable via CMake command line
or environment variables
Call Stack (most recent call first):
cmake/OpenCVDetectPython.cmake:271 (find_python)
CMakeLists.txt:598 (include)
解决方案:
桌面“计算机”右键选择“属性”,在弹出“系统”窗口左侧选择“高级系统设置”,弹出“系统属性窗口”。
依次选择“系统属性”>>>“高级”>>>“环境变量”,弹出“环境变量”窗口。
“系统变量”栏选择“新建”,按下图操作:
设置完毕后,重启电脑。