[英]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.