微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

CMake找不到Python 3

如何解决CMake找不到Python 3

以下是我在编译时的错误

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的目录?

解决方法

https://cmake.org/cmake/help/v3.18/module/FindPython.html中所述。要找到python解释器,您可以使用:

find_package (Python COMPONENTS Interpreter Development)

该模块最好用于Python版本3。如果未找到,则搜索版本2。要管理Python的并发版本3和2,请使用FindPython3和FindPython2模块,而不要使用此模块。

如果它不起作用。您可以设置:

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.

如同一页所述。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?