我在 Windows 上使用 cmake 版本 3.17 并使用以下代码来查找 Python3 解释器。
set(Python3_FIND_VIRTUALENV FIRST)
find_package(Python3 REQUIRED COMPONENTS Interpreter)
对于python3虚拟环境,它失败并出现以下错误
CMake Error at D:/.conan/b17c57/1/share/cmake-3.17/Modules/FindPython/Support.cmake:1313 (list):
list index: 10 out of range (-10, 9)
Call Stack (most recent call first):
D:/.conan/b17c57/1/share/cmake-3.17/Modules/FindPython3.cmake:311 (include)
我试图打印索引失败的 _Python3_INTERPRETER_PROPERTIES 的值。
0:Python
1:3
2:6
3:6
4:64
5:cp36-win_amd64
6:C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib
7:C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib
8:D:\work\projects\devops\cip\temp\cip_build_system\venv\Lib\site-packages
9:D:\work\projects\devops\cip\temp\cip_build_system\venv\Lib\site-packages
CMake Error at D:/.conan/b17c57/1/share/cmake-3.17/Modules/FindPython/Support.cmake:1297 (list):
list index: 10 out of range (-10, 9)
当我用 find_package(PythonInterp 3.5 REQUIRED) 替换它时,它适用于 _Python3_INTERPRETER_PROPERTIES 的以下值
0:Python
1:3
2:6
3:6
4:64
5:
6:cp36-win_amd64
7:C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib
8:C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib
9:D:\work\projects\devops\cip\temp\cip_build_system\venv\Lib\site-packages
10:D:\work\projects\devops\cip\temp\cip_build_system\venv\Lib\site-packages
在错误情况下,缺少 Python3_SOABI。知道如何解决这个问题,因为 PythonInterp 自 cmake 版本 3.12 以来已被弃用?