如何将easy_install指向vcvarsall.bat?

Mik*_*Lin 45 python distutils visual-studio-2010 easy-install

我已经安装了MSVC++ 2010 Express,而我的vcvarsall.bat文件C:\Program Files\Microsoft Visual Studio 10.0\VC位于我的系统PATH中.当我运行时easy_install,它找不到vcvarsall.bat.

我需要在distutils.cfg文件中设置一些东西来指向我的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
Run Code Online (Sandbox Code Playgroud)

Pio*_*ost 57

我还是想知道在哪里设置对vsvarsall.bat的引用...

好吧,正如martineau所写,你必须安装Visual Studio 2008或Visual C++ Express.说完了,我知道你想知道Python在哪里查找这个批处理文件.您可以通过查看distutils/msvc9compiler.py标准模块中definitionfind_vcvarsall函数来看到这一点.如果任何文件夹保存在注册表下的密钥下,Python会依次检查

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

(适用于64位Windows)或

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

(对于32位Windows)存在,如果存在,它将此类文件夹视为包含vcvarsall.bat文件的文件夹.如果这些文件夹都不存在,Python会检查是否存在环境变量VS90COMNTOOLS.如果此变量退出Python,则将此变量值的两个级别作为包含vcvarsall.bat文件的文件夹处理.

另请参阅我的其他答案,它解释了为什么您不能使用MSVC++ 2010来构建Python 2.6的扩展

编辑:VC++ 2008文件现在打包在MS的安装程序中,可以在此处下载.一旦安装vcvarsall.bat将在C:\Users\username\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0

  • 太糟糕的Python没有与gcc捆绑在一起.下载一个3.3GB VS 2008 iso只是为了能够在64位Windows和64位Python上使用setuptools是一种荒谬的做法. (56认同)
  • 由于MSVC++ 2008 Express不再可用,他们应该将Windows版本更新为[MSVC++ 2010 Express](http://www.visualstudio.com/en-us/downloads),这仍然可以获得 - 尽管这样做会有涟漪效应...... (7认同)
  • @tponthieux"微软已经发布了一个Python 2.7编译器包,使人们可以更轻松地在Windows上构建和分发他们的C扩展模块.用于Python 2.7的Microsoft Visual C++编译器(又名VC9)可从以下网址获得:http:// aka .ms/vcpython27""这是免费的(VC Express 2008最近落后于支付墙)它很小(下载85MB,安装300mb)这是一个不需要重启的每用户安装" - Steve Dower.有关公告,请参见https://mail.python.org/pipermail/distutils-sig/2014-September/024885.html. (6认同)
  • @tponthieux这就是为什么[安装](http://stackoverflow.com/a/5442340/95735)来自Windows上的二进制包是如此方便. (2认同)
  • @PiotrDobrogost真的.但是pypi上的许多软件包都没有预编译的二进制安装程序,因此从源代码安装是唯一的选择. (2认同)