简体   繁体   English

ValueError:尝试使用 mingw-w64 进行编译时,未知 MS 编译器版本 1916

[英]ValueError: Unknown MS Compiler version 1916 when trying to compile with mingw-w64

I'm trying to get Python packages built on my Windows machine using GCC instead of the MS C++ build tools, the former being much smaller (although still 1.5GB). I'm trying to get Python packages built on my Windows machine using GCC instead of the MS C++ build tools, the former being much smaller (although still 1.5GB).

I have setup mingw-w64 using MSYS2 , and it's in the path, so:我已经使用MSYS2设置了mingw-w64 ,它在路径中,所以:

C:\Users\username>where g++
c:\MyPrograms\msys64\mingw64\bin\g++.exe

C:\Users\username>g++ --version
g++ (Rev3, Built by MSYS2 project) 10.1.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

So far, so good.到目前为止,一切都很好。

I setup the distutils.cfg as follows, as described here :我设置distutils.cfg如下如下所述:

[build]
compiler=mingw32

[build_ext]
compiler=mingw32

But then installing a package such as astropy yields the following error:但随后安装 package(如astropy产生以下错误:

ValueError: Unknown MS Compiler version 1916

I saw somewhere a suggestion to fill distutils.cfg like this:我在某处看到了一个像这样填充distutils.cfg的建议:

[build]
compiler=g++

[build_ext]           
compiler=g++

which then raises:然后引发:

error: don't know how to compile C/C++ code on platform 'nt' with 'g++' compiler

Any idea?任何想法?

Edit: Full trace编辑:完整跟踪

    running build_ext
    running pre_hook from astropy.modeling.setup_package for build_ext command
    running pre_hook from astropy._erfa.setup_package for build_ext command
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\username\AppData\Local\Temp\pip-install-id1zp2pt\astropy\setup.py", line 35, in <module>
        setup(setup_requires=setup_requires)
      File "c:\users\username\appdata\local\temp\pip-install-id1zp2pt\astropy\astropy_helpers\astropy_helpers\setup_helpers.py", line 102, in setup
        setuptools_setup(**package_info)
      File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\setuptools\__init__.py", line 161, in setup
        return distutils.core.setup(**attrs)
      File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\users\username\appdata\local\temp\pip-install-id1zp2pt\astropy\astropy_helpers\astropy_helpers\setup_helpers.py", line 298, in run
        orig_run(self)
      File "c:\users\username\appdata\local\temp\pip-install-id1zp2pt\astropy\astropy_helpers\astropy_helpers\commands\build_ext.py", line 142, in run
        super().run()
      File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\setuptools\command\build_ext.py", line 87, in run
        _build_ext.run(self)
      File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run
        _build_ext.build_ext.run(self)
      File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\command\build_ext.py", line 306, in run
        self.compiler = new_compiler(compiler=self.compiler,
      File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\ccompiler.py", line 1032, in new_compiler
        return klass(None, dry_run, force)
      File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\cygwinccompiler.py", line 282, in __init__
        CygwinCCompiler.__init__ (self, verbose, dry_run, force)
      File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\cygwinccompiler.py", line 157, in __init__
        self.dll_libraries = get_msvcr()
      File "c:\users\username\appdata\local\programs\python\python38\lib\distutils\cygwinccompiler.py", line 86, in get_msvcr
        raise ValueError("Unknown MS Compiler version %s " % msc_ver)
    ValueError: Unknown MS Compiler version 1916
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\username\appdata\local\programs\python\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\username\\AppData\\Local\\Temp\\pip-install-id1zp2pt\\astropy\\setup.py'"'"'; __file__='"'"'C:\\Users\\username\\AppData\\Local\\Temp\\pip-install-id1zp2pt\\astropy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\username\AppData\Local\Temp\pip-record-zwu6d9vh\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\username\appdata\local\programs\python\python38\Include\astropy' Check the logs for full command output.

This is an issue that persists from visual studio 14, as reported in this https://bugs.python.org/issue25251 thread.这是 Visual Studio 14 中持续存在的问题,如此https://bugs.python.org/issue25251线程中所述。 I tried to patch it in various ways, but compiling python libraries with mingw32 looks to be broken since 2015.我尝试以各种方式对其进行修补,但自 2015 年以来,使用 mingw32 编译 python 库似乎已被破坏。

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

相关问题 未知的MS编译器版本1916 - 我正在尝试使用Flask运行Python并收到此错误 - Unknown MS Compiler Version 1916 - I'm trying to run Python with Flask and getting this error ValueError:未知的MS编译器版本1900 - ValueError: Unknown MS Compiler version 1900 如何使用 pip 在 Windows 7 上使用 MinGW-w64 编译器安装软件包? - How to use pip to install packages using MinGW-w64 compiler on Windows 7? 使用MinGW-w64时如何解决cython中的“未定义引用错误”错误? - How can I solve "undefined reference error to" error in cython when using MinGW-w64? 如何构建 setup.py 以使用 Python、pybind11 和 Mingw-w64 编译 C++ 扩展? - How can I build a setup.py to compile C++ extension using Python, pybind11 and Mingw-w64? cxfreeze 不在 mingw-w64 中复制 Qt6 Styles - Cxfreeze not copy Qt6 Styles in mingw-w64 MinGW-W64 安装中缺少 /bin 文件夹 - Missing /bin folder from MinGW-W64 installation Python:在 Windows 上选择 C++ 编译器 — MS Visual Studio 到 Mingw-w64。 (PyStan 编译错误) - Python: Choosing C++ compiler on Windows — MS Visual Studio to Mingw-w64. (PyStan CompileError) SQLite 使用 mingw-w64 编译扩展 Windows x64 - SQLite compiling extension Windows x64 with mingw-w64 如何使用 mingw-w64、Python 和 pybind11 手动构建 C++ 扩展? - How can I build manually C++ extension with mingw-w64, Python and pybind11?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM