web-dev-qa-db-fra.com

Comment puis-je pointer easy_install vers vcvarsall.bat?

J'ai déjà MSVC++ 2010 Express installé et mon fichier vcvarsall.bat est à C:\Program Files\Microsoft Visual Studio 10.0\VC, qui est dans mon système PATH. Quand je lance easy_install, il ne trouve pas vcvarsall.bat.

Y a-t-il quelque chose que je dois définir dans mon fichier distutils.cfg pour le pointer vers mon installation MSVC++?

G:\>easy_install hg-git
install_dir C:\Python26\Lib\site-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:\python26\lib\site-packages\hg_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.1\setup.py -q bdist_Egg --dist-dir c:\docume~1\mlin\locals~1
\temp\easy_install-fhraep\dulwich-0.7.1\Egg-dist-tmp-qozily
error: Setup script exited with error: Unable to find vcvarsall.bat
45
Mike M. Lin

Je voudrais toujours savoir où définir cette référence à vsvarsall.bat ...

Eh bien, comme Martin l'écrit, vous devez avoir Visual Studio 2008 ou Visual C++ Express installé. Cela dit, je comprends que vous souhaitez savoir où Python recherche ce fichier de commandes. Vous pouvez le voir en regardant definition of find_vcvarsall fonction dans le module standard distutils/msvc9compiler.py. Python vérifie à son tour si l'un des dossiers enregistrés dans le registre sous les clés

  • HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir
  • HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VCExpress\9.0\Setup\VC\ProductDir

(pour Windows 64 bits) ou

  • HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir
  • HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\9.0\Setup\VC\ProductDir

(pour Windows 32 bits) existe et si tel est le cas, il traite ce dossier comme celui contenant vcvarsall.bat fichier. Si aucun de ces dossiers n'existe Python vérifie s'il y a une variable d'environnement VS90COMNTOOLS. Si cette variable se termine Python traite le dossier deux niveaux au-dessus de la valeur de cette variable comme le dossier contenant vcvarsall.bat fichier.

Voir aussi ma réponse other qui explique pourquoi vous ne pouvez pas utiliser MSVC++ 2010 pour créer des extensions pour Python 2.6

EDIT: Les fichiers VC++ 2008 sont maintenant emballés dans un programme d'installation de MS qui peut être téléchargé ici . Une fois installé, vcvarsall.bat sera dans C:\Users\username\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0

57
Piotr Dobrogost