如何将 easy_install 指向 vcvarsall.bat? [英] How do I point easy_install to vcvarsall.bat?

查看:19
本文介绍了如何将 easy_install 指向 vcvarsall.bat?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 MSVC++ 2010 Express,并且我的 vcvarsall.bat 文件位于 C:Program FilesMicrosoft Visual Studio 10.0VC,它在我的系统路径中.当我运行 easy_install 时,它找不到 vcvarsall.bat.

是否需要在我的 distutils.cfg 文件中设置一些内容以将其指向我的 MSVC++ 安装?

G:>easy_install hg-gitinstall_dir C:Python26Libsite-packages搜索 hg-git最佳匹配:hg-git 0.2.6处理 hg_git-0.2.6-py2.6.egghg-git 0.2.6 已经是 easy-install.pth 中的活动版本使用 c:python26libsite-packageshg_git-0.2.6-py2.6.egg处理 hg-git 的依赖项搜索德威>=0.6.0阅读 http://pypi.python.org/simple/dulwich/阅读 http://samba.org/~jelmer/dulwich阅读 http://launchpad.net/dulwich最佳匹配:德威0.7.1下载 http://www.samba.org/~jelmer/dulwich/dulwich-0.7.1.tar.gz处理 dulwich-0.7.1.tar.gz运行 dulwich-0.7.1setup.py -q bdist_egg --dist-dir c:docume~1mlinlocals~1	empeasy_install-fhraepdulwich-0.7.1egg-dist-tmp-qozily错误:安装脚本退出并出现错误:无法找到 vcvarsall.bat

解决方案

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

好吧,正如 martineau 所写,您必须安装 Visual Studio 2008 或 Visual C++ Express.话虽如此,我知道您想知道 Python 在哪里查找此批处理文件.您可以通过查看 definitionfind_vcvarsall 函数的/code>.Python 依次检查是否有任何文件夹保存在注册表项下

  • HKEY_LOCAL_MACHINESoftwareWow6432NodeMicrosoftVisualStudio9.0SetupVCProductDir
  • HKEY_LOCAL_MACHINESoftwareWow6432NodeMicrosoftVCExpress9.0SetupVCProductDir

(对于 64 位 Windows)或

  • HKEY_LOCAL_MACHINESoftwareMicrosoftVisualStudio9.0SetupVCProductDir
  • HKEY_LOCAL_MACHINESoftwareMicrosoftVCExpress9.0SetupVCProductDir

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

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

VC++ 2008 文件现在打包在 MS 的安装程序中,可以下载 这里.安装后 vcvarsall.bat 将位于 C:UsersusernameAppDataLocalProgramsCommonMicrosoftVisual C++ for Python9.0

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
	empeasy_install-fhraepdulwich-0.7.1egg-dist-tmp-qozily
error: Setup script exited with error: Unable to find vcvarsall.bat

解决方案

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

这篇关于如何将 easy_install 指向 vcvarsall.bat?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆