美文网首页代码
Python之Unable to find vcvarsall.

Python之Unable to find vcvarsall.

作者: 寂寞的原子 | 来源:发表于2015-12-28 00:04 被阅读64次

    Windows上Python安装点什么,如果需要编译,很有可能就出现这个错误了:

    Unable to find vcvarsall.bat
    

    这个错误的原因很简单,就是找不到MSVC的编译器,而我就是不想用MSVC,我喜欢MinGW,于是配置一下:

    1. 写入$PYTHON_PATH/Lib/distutils/distutils.cfg
    [build]
    compiler=mingw32
    

    以前这样就大功告成了,但是现在MSVC版本太多,Python有点跟不上了(MinGW最终也是要调用MSVCRT库的),于是需要再打个补丁。(参考StackOverflow

    1. 修改$PYTHON_PATH/Lib/distutils/cygwinccompiler.py
       # ...
       elif msc_ver == '1600':
           # VS2010 / MSVC 10.0
           return ['msvcr100']
       # 添加以下内容:
       elif msc_ver == '1700':
           # Visual Studio 2012 / Visual C++ 11.0
           return ['msvcr110']
       elif msc_ver == '1800':
           # Visual Studio 2013 / Visual C++ 12.0
           return ['msvcr120']
       elif msc_ver == '1900':
           # Visual Studio 2015 / Visual C++ 14.0
           # "msvcr140.dll no longer exists" http://blogs.msdn.com/b/vcblog/archive/2014/06/03/visual-studio-14-ctp.aspx
           return ['vcruntime140']
    

    相关文章

      网友评论

      • JetLu:记得以前好像遇到过

      本文标题:Python之Unable to find vcvarsall.

      本文链接:https://www.haomeiwen.com/subject/lkvbhttx.html