首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >CMake找不到Python3

CMake找不到Python3
EN

Stack Overflow用户
提问于 2020-11-03 12:04:38
回答 1查看 3.1K关注 0票数 0

以下是我编译时的错误:

代码语言:javascript
运行
复制
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
  Could NOT find PythonInterp: Found unsuitable version "2.7.16", but
  required is at least "3" (found /usr/bin/python)
Call Stack (most recent call first):
  /Applications/CMake.app/Contents/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:456 (_FPHSA_FAILURE_MESSAGE)
  /Applications/CMake.app/Contents/share/cmake-3.18/Modules/FindPythonInterp.cmake:169 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  3rdparty/pybind11/tools/FindPythonLibsNew.cmake:60 (find_package)
  3rdparty/pybind11/tools/pybind11Tools.cmake:16 (find_package)
  3rdparty/pybind11/CMakeLists.txt:33 (include)

如何更改CMake查找python的目录?

EN

Stack Overflow用户

发布于 2020-11-04 01:38:14

正如在https://cmake.org/cmake/help/v3.18/module/FindPython.html中提到的。要查找python解释器,您可以使用:

代码语言:javascript
运行
复制
find_package (Python COMPONENTS Interpreter Development)

这个模块看起来更适合Python的版本3。如果未找到,则搜索版本2。要管理并发版本3和2的Python3和2,请使用FindPython3和FindPython2模块,而不是这个模块。

如果它不工作的话。您可以设置:

代码语言:javascript
运行
复制
Python_EXECUTABLE

    The path to the interpreter.
Python_COMPILER

    The path to the compiler.
Python_DOTNET_LAUNCHER

    The .Net interpreter. Only used by IronPython implementation.
Python_LIBRARY

    The path to the library. It will be used to compute the variables Python_LIBRARIES, Python_LIBRAY_DIRS and Python_RUNTIME_LIBRARY_DIRS.
Python_INCLUDE_DIR

    The path to the directory of the Python headers. It will be used to compute the variable Python_INCLUDE_DIRS.
Python_NumPy_INCLUDE_DIR

    The path to the directory of the NumPy headers. It will be used to compute the variable Python_NumPy_INCLUDE_DIRS.

正如在同一页中所提到的。

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64656663

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档