简体   繁体   English

Python 脚本:如何修复 CMake 错误:无法创建命名生成器?

[英]Python script: how to fix CMake Error: Could not create named generator?

  • OS: Windows 10操作系统:Windows 10
  • CMake: 3.18.2 CMake:3.18.2
  • MSVC: 16.7.3 MSVC:16.7.3

When I use command line I can generate build with following line当我使用命令行时,我可以使用以下行生成构建

cmake -B "D:\Builds" -S "D:\src" -G "Visual Studio 16 2019" -A "x64" 

When I use followed Pytnon script:当我使用以下 Pytnon 脚本时:

subprocess.call([
    '...\cmake.exe', 
    '-B "D:\Builds"',
    '-S "D:\src"',
    '-G "Visual Studio 16 2019"',
    '-A "x64"'
])

I receive an error:我收到一个错误:

CMake Error: Could not create named generator  "Visual Studio 16 2019"

Why it happens and how to fix it?为什么会发生以及如何解决?

PS: this is not duplicate of any questions, this is new PS:这不是任何问题的重复,这是新的

Update1 : When I change generator line to the Update1 :当我将发电机线更改为

'-G Visual Studio 16 2019'

I see the followed error:我看到以下错误:

CMake Error: Could not create named generator  Visual Studio 16 2019

So I think it is not doublequotes fall所以我认为这不是双引号下降

It looks like you may have two versions of CMake installed.看起来您可能安装了两个版本的 CMake。 Be sure the one used in your Python script is greater than or equal to CMake version 3.14.确保 Python 脚本中使用的版本大于或等于 CMake 3.14 版。 The Visual Studio 16 2019 generator is not available in earlier CMake versions. Visual Studio 16 2019生成器在早期 CMake 版本中不可用。

You can test your CMake version used by the Python script by adding:您可以通过添加以下内容来测试 Python 脚本使用的 CMake 版本:

subprocess.call([
    '...\cmake.exe', 
    '--version'
])

For me, a similar problem was resolved by removing the quotes within the quotes in Python, as hinted at in @Tsyvarev's comment above.对我来说,通过删除 Python 中引号中的引号解决了类似的问题,正如上面@Tsyvarev 的评论中所暗示的那样。 IOW:爱荷华州:

subprocess.call(['cmake', '-G', '"Visual Studio 16 2019"']) # Fails
subprocess.call(['cmake', '-G', 'Visual Studio 16 2019'])   # Succeeds

Or if you want one generator arg:或者,如果您想要一个生成器 arg:

subprocess.call(['cmake', '-G"Visual Studio 16 2019"']) # Fails
subprocess.call(['cmake', '-GVisual Studio 16 2019'])   # Succeeds

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从python脚本调用CMake导致“无法创建命名生成器” - Call CMake from python script results in “Could not create named generator” 如何修复 Python 中的“ImportError: No module named ...”错误? - How to fix “ImportError: No module named …” error in Python? 如何解决以下Python错误:没有名为Playback的模块? - How do i fix the following Python error: no module named Playback? 如何使用 VScode 在 python 中修复导入错误:No module named... - how to fix Import Error: No module named... in python with VScode 如何修复python3.8中的错误“没有名为'builtin'的模块” - how to fix error "No module named 'builtin'" in python3.8 如何修复 python2.7 中的“导入错误:没有命名的模块” - How to fix 'Import Error: No module named' in python2.7 如何修复 CMakeLists.txt 中的 CMake 错误:生成器 NMake Makefiles 不支持平台规范,但已指定平台 x64 - how to fix CMake Error in CMakeLists.txt: Generator NMake Makefiles does not support platform specification, but platform x64 was specified 如何修复 emailcheck python 脚本中的 output 错误 - how to fix output error in emailcheck python script 如何修复 ALDialog Python 脚本 NAOqi 错误 - How to fix ALDialog Python Script NAOqi Error 找不到python解释器-Opencv cmake错误 - Could not find python Interpreter - Opencv cmake error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM