我如何将 easy_install 指向 vcvarsall.bat?
- 2025-03-21 09:07:00
- admin 原创
- 37
问题描述:
我已经安装了 MSVC++ 2010 Express,并且我的 vcvarsall.bat 文件位于C:Program FilesMicrosoft Visual Studio 10.0VC
,它位于我的系统 PATH 中。当我运行 时easy_install
,它找不到 vcvarsall.bat。
我需要在 distutils.cfg 文件中设置一些内容以将其指向我的 MSVC++ 安装吗?
G:>easy_install hg-git
install_dir C:Python26Libsite-packages\nSearching 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
解决方案 1:
我仍然想知道在哪里设置对 vsvarsall.bat 的引用...
好吧,正如 martineau 所写,您必须安装 Visual Studio 2008 或 Visual C++ Express。话虽如此,我知道您想知道 Python 在哪里查找此批处理文件。您可以通过查看 distutils/msvc9compiler.py 标准模块中的函数来查看definition
。Pythonfind_vcvarsall
依次检查注册表中是否存在保存在键下的文件夹
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:Users/usernameAppDataLocalProgramsCommonMicrosoftVisual C++ for Python9.0
解决方案 2:
在 python 3.9.12 (anaconda) 上遇到同样的问题,我在
C:\Users\UserName\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0安装了 Visual C++ for Python
并找到 msvc9compiler.py
C:\Users\UserName\anaconda3\Lib\distutils
显示
VS_BASE = r“Software\Microsoft\VisualStudio%0.1f”
如何将 vcvarsall.bat 指向 python?
(我添加了系统 PATH 但根本不起作用。)
C:\Users\UserName\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
您能指出如何为该值添加注册表吗?我在我的电脑上找不到 HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir。
扫码咨询,免费领取项目管理大礼包!