如何将 easy_install 指向 vcvarsall.bat?
我已经安装了 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
I already have MSVC++ 2010 Express installed, and my vcvarsall.bat file is at C:\Program Files\Microsoft Visual Studio 10.0\VC
, 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:\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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,正如 martineau 所写,您必须安装 Visual Studio 2008 或 Visual C++ Express。话虽如此,我知道您想知道 Python 在哪里查找这个批处理文件。您可以通过查看
definition< 来看到这一点distutils/msvc9compiler.py 标准模块中
find_vcvarsall
函数的 /code>。 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 的安装程序中,可以下载
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
offind_vcvarsall
function in distutils/msvc9compiler.py standard module. Python checks in turn if any of folders saved in the registry under keysHKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VCExpress\9.0\Setup\VC\ProductDir
(for 64bit Windows) or
HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir
HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\9.0\Setup\VC\ProductDir
(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 variableVS90COMNTOOLS
. If this variable exits Python treats folder two levels above value of this variable as the folder containingvcvarsall.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:\Users\username\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
在 python 3.9.12 (anaconda) 上遇到同样的问题,我安装 Visual C++ for Python
C:\Users\UserName\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
找到 msvc9compiler.py
并在C:\ 用户\用户名\anaconda3\Lib\distutils
显示
VS_BASE = r"Software\Microsoft\VisualStudio%0.1f"
如何将 vcvarsall.bat 指向 python ?
(我添加了系统路径但根本不起作用。)
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
在我的电脑中。
Met same problem on python 3.9.12 (anaconda),I install Visual C++ for Python at
C:\Users\UserName\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
and find the msvc9compiler.py at
C:\Users\UserName\anaconda3\Lib\distutils
showed
VS_BASE = r"Software\Microsoft\VisualStudio%0.1f"
how to point the vcvarsall.bat to python ?
(I added the system PATH but not working at all.)
C:\Users\UserName\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
May you please point out how to add registry for the value?
I did't find HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\9.0\Setup\VC\ProductDir
in my PC.