一直在用Linux, 最近想在windows下使用Python。
当我想安装Matplotlib module的时候, 出现以下错误。Microsoft Visual C++ 9.0 is required < Unable to find vcvarsall.bat>
想起来自己一直没有安装VS - -!。 后来安装之后错误依旧。
后续解决办法如下:
For Windows installations:
While running setup.py 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 in VS90COMNTOOLS
environment variable before calling setup.py
.
Execute the following command based on the version of Visual Studio installed:
- Visual Studio 2010 (VS10):
SET VS90COMNTOOLS=%VS100COMNTOOLS%
- Visual Studio 2012 (VS11):
SET VS90COMNTOOLS=%VS110COMNTOOLS%
- Visual Studio 2013 (VS12):
SET VS90COMNTOOLS=%VS120COMNTOOLS%
python27在运行setup.py安装时, 会默认寻找visual studio 2008来编译其中的C++文件。 但我安装的是VS2013, 所以需要运行
SET VS90COMNTOOLS=%VS120COMNTOOLS% 改变配置。
然后错误消失了。
但出现了新的错误。 如下:
valueerror(str(list(result.keys()))) valueerror u'path'
于是继续搜。。。 。http://stackoverflow.com/questions/3047542/building-lxml-for-python-2-7-on-windows/5122521#5122521
I bet you're not using VS 2008 for this :)
There's def 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 does not check 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 at 11.4. distutils.msvccompiler — Microsoft Compiler section 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 titled Download Visual Studio Express 2008 now on 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.
简言之:看到最终的解决办法如下:
必须安装VS2008.。。。。。。。。。。。。
追加(如果你不想安装vs2008):
最终解决办法:
Microsoft Visual C++ Compiler for Python 2.7
over.....