为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.

报错1

不知为何,我的电脑死活不能安装上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

报错2

编辑你的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

posted @   wsm25  阅读(607)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示