如何解决Windows系统下pip安装包错误Unable to find vcvarsall.bat

简介

在Windows系统上,通过pip安装Python包时,会报”error: Unable to find vcvarsall.bat”错误。手工安装时,也会有同样的问题:
> python setup.py install
running build_ext
building 'dulwich._objects' extension

error: Unable to find vcvarsall.bat

问题分析

为生成Python包的二进制轮子(binary wheel),需要安装编译器和系统头文件。Microsoft Visual C++ Compiler for Python 2.7提供了包含了需要的编译器和系统头文件集,这样就可以不需要访问C编译器,便可在任何Windows系统上安装Python包的二进制轮子。如果你没有安装这个编译器包,遇到的典型的错误就是”Unable
to find vcvarsall.bat“。
下面是官方关于此包的详细说明:
This package contains the compiler and set of system headers necessary for producing binary
wheels for Python packages. A binary wheel of a Python package can then be installed on any Windows system without requiring access to a C compiler.
The typical error message you will receive if you need this compiler package is Unable
to find vcvarsall.bat
This message appears because the Python package being installed contains the source code for
a native extension module (.pyd), but does not have a pre-built copy of the module. The Python packages highlighted at 
pythonwheels.com have
already been updated by their developers to include pre-built binaries, but many are still only available as source code.
This compiler package is entirely unsupported and represents a snapshot of the
last version that is fully compatible with Python 2.7. For the latest security and bug fixes, please use the latest version of 
Microsoft
Visual Studio
 for any development work that does not directly interface with Python 2.7.

解决方案

去微软官网下载VCForPython27.msi安装即可:

转载自:https://blog.csdn.net/jinguangliu/article/details/71298388

You may also like...

退出移动版