我安装了 2 个版本的 python,但 cmake 使用的是旧版本.如何强制 cmake 使用较新版本? [英] I have 2 versions of python installed, but cmake is using older version. How do I force cmake to use the newer version?

查看:54
本文介绍了我安装了 2 个版本的 python,但 cmake 使用的是旧版本.如何强制 cmake 使用较新版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了 2 个版本的 python,但 cmake 使用的是旧版本.如何强制 cmake 使用较新的版本?

I have 2 versions of python installed, but cmake is using older version. How do I force cmake to use the newer version?

推荐答案

您可以根据需要尝试以下任一方法:

You may try either of these depending on what you need:

根据变更日志:

新的FindPython3"和FindPython2"模块,以及一个新的
已添加FindPython"模块以提供一种新的定位方式
python环境.

New "FindPython3" and "FindPython2" modules, as well as a new
"FindPython" module, have been added to provide a new way to locate
python environments.

find_package(Python COMPONENTS Interpreter Development)

文档:

该模块最好用于 Python 版本 3.如果没有找到,版本 2 被搜索.管理并发版本 3 和 2Python,使用 FindPython3 和 FindPython2 模块而不是这个模块.

This module looks preferably for version 3 of Python. If not found, version 2 is searched. To manage concurrent versions 3 and 2 of Python, use FindPython3 and FindPython2 modules rather than this one.

对于 CMake <3.12

文档:

find_package(PythonInterp 2.7 REQUIRED)
find_package(PythonLibs 2.7 REQUIRED)

这篇关于我安装了 2 个版本的 python,但 cmake 使用的是旧版本.如何强制 cmake 使用较新版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆