为MinGW配置Python - 解决问题 error: Microsoft Visual C++ 14.0 is required 和 ValueError: Unknown MS Compiler version
众所周知,很多Python的库都需要编译(可能是用了Cython),这时直接用pip安装会报错:error: Microsoft Visual C++ 14.0 is required.

不知为何,我的电脑死活不能安装上VC,只能用mingw作为编译器。
附:MinGW-w64 密码:2jfy,tdm64-gcc tdm-gcc(32位)
最新版:tdm-gcc GCC with the MCF thread model MinGW-w64
环境变量:[Windows配置MinGW环境变量]
然后编辑你的 Python 路径/Lib/distutils/distutils.cfg 或者 %USERPROFILE%\pydistutils.cfg
[build]
compiler=mingw32
[build_ext]
compiler = mingw32
# To solve the gcc error of "error: enumerator value for '__pyx_check_sizeof_voidp' is not an integer constant"
# if you have a mingw for 64bit then
# refer to https://docs.python.org/zh-cn/3/distutils/configfile.html
# you can also refer to https://github.com/cython/cython/issues/3405#issuecomment-596975159
define = MS_WIN64
仍然会报错 Unknown MS Compiler version XXXX

编辑你的Python路径/Lib/distutils/cygwinccompiler.py
在
elif msc_ver == '1600':
# VS2010 / MSVC 10.0
return ['msvcr100']
后添加
elif msc_ver == '1927':
# MinGW64 with gcc 8.3.0
return ['msvcr120'] # seem to be a dynamic-linker program name for command `ld`
其中1927改为你的Compiler version

浙公网安备 33010602011771号