How do I point easy_install to vcvarsall.bat?

Question:

I already have MSVC++ 2010 Express installed, and my vcvarsall.bat file is at C:Program FilesMicrosoft Visual Studio 10.0VC, which is in my system PATH. When I run easy_install, it can’t find vcvarsall.bat.

Is there something I need to set in my distutils.cfg file to point it to my MSVC++ installation?

G:>easy_install hg-git
install_dir C:Python26Libsite-packages
Searching for hg-git
Best match: hg-git 0.2.6
Processing hg_git-0.2.6-py2.6.egg
hg-git 0.2.6 is already the active version in easy-install.pth

Using c:python26libsite-packageshg_git-0.2.6-py2.6.egg
Processing dependencies for hg-git
Searching for dulwich>=0.6.0
Reading http://pypi.python.org/simple/dulwich/
Reading http://samba.org/~jelmer/dulwich
Reading http://launchpad.net/dulwich
Best match: dulwich 0.7.1
Downloading http://www.samba.org/~jelmer/dulwich/dulwich-0.7.1.tar.gz
Processing dulwich-0.7.1.tar.gz
Running dulwich-0.7.1setup.py -q bdist_egg --dist-dir c:docume~1mlinlocals~1
tempeasy_install-fhraepdulwich-0.7.1egg-dist-tmp-qozily
error: Setup script exited with error: Unable to find vcvarsall.bat
Asked By: Mike M. Lin

||

Answers:

I’d still like to know where to set that reference to vsvarsall.bat…

Well, as martineau wrote you have to have either Visual Studio 2008 or Visual C++ Express installed. Having said that I understand you would like to know where Python looks for this batch file. You can see this by looking at definition of find_vcvarsall function in distutils/msvc9compiler.py standard module. Python checks in turn if any of folders saved in the registry under keys

  • HKEY_LOCAL_MACHINESoftwareWow6432NodeMicrosoftVisualStudio9.0SetupVCProductDir
  • HKEY_LOCAL_MACHINESoftwareWow6432NodeMicrosoftVCExpress9.0SetupVCProductDir

(for 64bit Windows) or

  • HKEY_LOCAL_MACHINESoftwareMicrosoftVisualStudio9.0SetupVCProductDir
  • HKEY_LOCAL_MACHINESoftwareMicrosoftVCExpress9.0SetupVCProductDir

(for 32bit Windows) exists and if so it treats such folder as the one containing vcvarsall.bat file. If none of these folders exists Python checks if there’s environment variable VS90COMNTOOLS. If this variable exits Python treats folder two levels above value of this variable as the folder containing vcvarsall.bat file.

See also my other answer which explains why you can’t use MSVC++ 2010 to build extensions for Python 2.6

EDIT:
The VC++ 2008 files are now packaged in an installer from MS which can be downloaded here. Once installed vcvarsall.bat will be in C:UsersusernameAppDataLocalProgramsCommonMicrosoftVisual C++ for Python9.0

Answered By: Piotr Dobrogost

Met same problem on python 3.9.12 (anaconda),I install Visual C++ for Python at
C:UsersUserNameAppDataLocalProgramsCommonMicrosoftVisual C++ for Python9.0

and find the msvc9compiler.py at

C:UsersUserNameanaconda3Libdistutils
showed
VS_BASE = r"SoftwareMicrosoftVisualStudio%0.1f"

how to point the vcvarsall.bat to python ?

(I added the system PATH but not working at all.)
C:UsersUserNameAppDataLocalProgramsCommonMicrosoftVisual C++ for Python9.0

May you please point out how to add registry for the value?
I did’t find HKEY_LOCAL_MACHINESoftwareMicrosoftVisualStudio9.0SetupVCProductDir
in my PC.

Answered By: 楊宇恩