Recently wanted to learn about Python's Paramiko library, Paramiko relies on Pycrypto, when compiling Pycrypto encountered a problem, the general meaning is:
unable to find vcvarsall.bat
Problem Analysis:
Follow the error message and navigate to the following file
python_path/lib/distutils/msvc9compiler.py
Simple analysis of the source code, found that when compiling the extension library, the function provided in this file to determine the path of Vcvarsall.bat to set the VC environment variables,
A global variable is defined in the msvc9compiler.py
VERSION = get_build_version()
Use the Get_build_version () function to get the version number of the VC, and this version is actually compiled Python is the VC version, probably because most people's python is not compiled by themselves, resulting in the version of the VC obtained through this function is not accurate.
In msvc9compiler.py, a class msvccompiler is defined:
class MSVCCompiler(CCompiler) :
"""Concrete class that implements an interface to Microsoft Visual C++,
as defined by the CCompiler abstract class."""
The VC environment variable is set in the initialization function initialize of the Msvccompiler class, that is, the path of the Vcvarsall.bat is obtained through a series of functions:
#初始化函数initialize首先调用query_vcvarsall
vc_env = query_vcvarsall(VERSION, plat_spec) #VERSION为上面提到的全局变量
#vc_env调用find_vcvarsall
vcvarsall = find_vcvarsall(version) #find_vcvarsall查找vcvarsall.bat的路径,参数version=VERSION
If the value of version does not match the version of the VC that is installed natively, you will not find the Vcvarsall.bat.
Workaround:
Modify Code
VERSION = get_build_version()
For
VERSION = 10.0 #10.0为VC的版本号
The specific version number differs according to the actual installation of Visual Studio, VS2010 is 10.0.
From for notes (Wiz)
Compiled Python extension library encountered "Unable to find Vcvarsall.bat" workaround