PCYO 评测夜鸥 六度计算世界

少年强 则 中国强

pip编译C的包绕过VC14要求,改为mingw64

众所周知,很多Python的库都需要编译(大概率是用了Cython),这时直接用pip安装会报错:error: Microsoft Visual C++ 14.0 is required.

不知为何,我的电脑死活不能安装上VC,只能用mingw作为编译器。

  1. 编辑你的Python路径/Lib/distutils/distutils.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 install a mingw for 64bit thendefine = MS_WIN64 

仍然会报错 Unknown MS Compiler version XXXX

  1. 编辑你的Python路径/Lib/distutils/cygwinccompiler.py

    elif msc_ver == '1600': 
    # VS2010 / MSVC 10.0 
    return ['msvcr100'] 

    后添加

     elif msc_ver == '1927' or msc_ver=='1929': 
     # MinGW64 with gcc 8.3.0 兼容 gcc version 8.1.0 (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 
     return ['msvcr120'] # seem to be a dynamic-linker program name for command `ld` 

    其中1927改为你的Compiler version

本原创文章未经允许不得转载 | 当前页面:PCYO 评测夜鸥 六度计算世界 » pip编译C的包绕过VC14要求,改为mingw64

评论