【问题标题】:CMake can not find Python 3 [duplicate]CMake找不到Python 3 [重复]
【发布时间】:2020-11-03 04:04:37
【问题描述】:

以下是我编译时的错误:

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

【问题讨论】:

    标签: python-3.x cmake pybind11 cmake-gui openpose


    【解决方案1】:

    如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.
    

    如同一页所述。

    【讨论】:

    • 您好,感谢您的回答,但我已经在另一个堆栈溢出线程上找到了解决方案。我已将我的问题相应地标记为重复,并且正在等待批准。再次感谢您的意见。
    猜你喜欢
    • 2017-07-02
    • 2022-01-02
    • 1970-01-01
    • 2020-11-10
    • 2019-12-13
    • 2017-12-25
    • 1970-01-01
    • 2017-05-17
    • 1970-01-01
    相关资源
    最近更新 更多