Python: Windows下pip安装库出错:Microsoft Visual C++ 9.0 is required < Unable to find vcvarsall.bat

2017-01-13 10:52:19来源:csdn作者:roler_人点击

一直在用Linux, 最近想在windows下使用python。

当我想安装Matplotlib module的时候, 出现以下错误。Microsoft Visual C++ 9.0 is required < Unable to find vcvarsall.bat>

想起来自己一直没有安装VS - -!。 后来安装之后错误依旧。


For Windows installations:

While running for package installations, Python 2.7 searches for an installed Visual Studio 2008. You can trick Python to use a newer Visual Studio by setting the correct path inVS90COMNTOOLSenvironment
variable before

Execute the following command based on the version of Visual Studio installed:

Visual Studio 2010 (VS10):SET
Visual Studio 2012 (VS11):SET
Visual Studio 2013 (VS12):SET

python27在运行setup.py安装时, 会默认寻找visual studio 2008来编译其中的C++文件。 但我安装的是VS2013, 所以需要运行SET VS90COMNTOOLS=%VS120COMNTOOLS% 改变配置。


但出现了新的错误。 如下:

valueerror(str(list(result.keys()))) valueerror u'path'

于是继续搜。。。 。

I bet you're not using VS 2008 for this :)

find_vcvarsall(version):function (guess what, it looks for vcvarsall.bat) in distutils with the following comment

At first it tries to find the productdir of VS 2008 in the registry. If that fails it falls back to the VS90COMNTOOLS env var.

If you're not using VS 2008 then you have neither the registry key nor suitable environment variable and that's why distutils can't find vcvarsall.bat file. It doesnotcheck
if the bat file is reachable through the PATH environment variable.

The solution is to define VS90COMNTOOLS variable to point to Tools directory of Visual Studio.

That being said take a look at11.4.
distutils.msvccompiler — Microsoft Compilersection in Python's docs which states

Typically, extension modules need to be compiled with the same compiler that was used to compile Python.

Martin v. Loewis in the email titledDownload
Visual Studio Express 2008 nowon python-list mailing list states the same

Python 2.6, 2.7, and 3.1 are all built with that release (i.e. 2008). Because of another long tradition, Python extension modules must be built with the same compiler version (more specifically, CRT version) as Python itself. So to build extension modules for
any of these releases, you need to have a copy of VS 2008 or VS 2008 Express.





Microsoft Visual C++ Compiler for Python 2.7