为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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现