Python PIP 在 Windows 7 上用于 64 位安装的 MS Visual Studio 2010 Express 的路径有问题 [英] Python PIP has issues with path for MS Visual Studio 2010 Express for 64-bit install on Windows 7

查看:24
本文介绍了Python PIP 在 Windows 7 上用于 64 位安装的 MS Visual Studio 2010 Express 的路径有问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个全新安装的 64 位 python 3.3 虚拟环境.(注意:我在我的计算机上安装了几个 python,包括 WinPython,但想为我正在处理的几个项目设置干净和小的虚拟环境.WinPython 版本工作得很好.)当我使用 pip 尝试安装包时,我收到一条错误消息(如果需要,可以包含 pip 日志).最终,错误消息的最后几行是:

I was creating a virtualenv with a clean install of python 3.3, 64-bit version. (Note: I have several installs of python on my computer including WinPython but want to set up clean and small virtualenvs for several projects that I am working on. The WinPython version works just fine.) When I used pip to try to install packages, I got an error message (can include pip log if requested). Ultimately, the last lines of the error message were:

File "c:python33-bLibdistutilsmsvc9compiler.py", line 287, in query_vcvarsall raise ValueError(str(list(result.keys())))

ValueError: ['path']

我调查了 msvc9compiler.py 中函数 query_vcvarsall 的结果.我发现这个函数正在我的计算机上从 MS Visual Studio 10 Express 寻找 vcvarsall 的路径.它正在寻找 4 个组件:INCLUDE=、PATH=、LIB= 和 LIBPATH=.这些是特定于 MS VS 2010 的.我的安装向此函数发送了amd64"参数.除了 PATH= 语句外,它什么也没找到,但确实找到了 vcvarsall.bat 文件.当我欺骗这个函数使用x86"参数时,它找到了所有 4 个语句,并且看起来好像可以正常运行.

I investigated the results from the function query_vcvarsall in the msvc9compiler.py. I found out that this function was looking for the path of vcvarsall from MS Visual Studio 10 Express on my computer. It is looking for 4 components: INCLUDE=, PATH=, LIB=, and LIBPATH=. These were specific for MS VS 2010. My install sent an argument of "amd64" to this function. It did not find anything but the PATH= statement but it did find the vcvarsall.bat file. When I tricked this function to use the "x86" argument, it found all of the 4 statements and appeared as if it would run fine.

我花了一些时间在网上研究这个.我发现 MS VS Express 2010 默认安装为 32 位.必须将其设置为 64 位运行(这意味着它将设置上述所需的语句.)显然存在一个错误,并且此版本未安装 64 位工具.所以我安装了 MS SDK 以安装 64 位工具.然后我发现有一个修复程序并安装了它(在下面的链接中列出).

I spent some time researching this on the web. I found that MS VS Express 2010 installs by default as 32-bit. One has to set it to run as 64-bit (which means it will set the statements needed above.) Apparently there was a bug and the 64-bit tools were not installed with this version. So I installed MS SDK in order to install the 64-bit tools. I then found there was a fix to this and installed that (listed below in links).

概述了为 64 位 VS 创建路径的几种方法.一种是在 MS VS 的命令行上运行 vcvarsall amd64.这导致出现一条消息,指出我的计算机上未安装这些工具.这些工具位于 C:Program Files (x86)Microsoft Visual Studio 10.0VCinamd64 目录中.它显然正在寻找的文件是 vcvars64.bat (或类似的东西).我有目录但没有批处理文件.(有人建议使用 x86_amd64 方法,但它有所有相同的问题.)

There were several methods outlined to create the paths for the 64-bit VS. One was to run vcvarsall amd64 on the command line for MS VS. This resulted in a message saying the tools were not installed on my computer. These tools were to reside in the C:Program Files (x86)Microsoft Visual Studio 10.0VCinamd64 directory. The file that it apparently is looking for is vcvars64.bat (or something similar). I have the directory but not the batch file. (There was a recommendation to use the x86_amd64 method but it has all of the same issues.)

第二个建议是从 SDK 命令行运行 setenv/x64.我运行了它,它似乎运行正确.但是,当我尝试通过 pip 安装软件包时,我收到了相同的错误消息.

The second recommendation was to run setenv /x64 from the SDK command line. I ran that and it seemed to run correctly. However, when I went I tried to install packages via pip, I got the same error message.

我的问题最终是如何让 pip 顺利运行?只是提一下,是的,在每次安装后再次测试 pip 并尝试修复此问题之前,我确实重新启动了.

My question ultimately is how to get pip running smoothly? Just to mention, yes, I did reboot before I tested pip again after each install and attempt at fixing this.

以下是一些帮助我走到这一步的网站:

Here are some sites that helped me get this far:

1) 启动 64 位命令提示符来自 Visual Studio 2010

2) 为 MS VS 2010 命令行构建设置路径和环境变量:
http://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx

2) Setting the Path and Environment Variables for MS VS 2010 Command-Line Builds:
http://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx

3) VS2010 Express 和缺少 x64 编译器:
https://social.msdn.microsoft.com/Forums/en-US/e0ef4613-d90f-4eec-90db-41339ed31367/vs2010-express-and-missing-x64-compiler?forum=Vsexpressinstall

3) VS2010 Express and missing x64 compiler:
https://social.msdn.microsoft.com/Forums/en-US/e0ef4613-d90f-4eec-90db-41339ed31367/vs2010-express-and-missing-x64-compiler?forum=Vsexpressinstall

4) 修复:如果安装了 Windows SDK v7.1,则在将 Visual Studio 2010 Professional 或 Visual Studio 2010 Express 升级到 Visual Studio 2010 SP1 时删除 Visual C++ 编译器:
http://support.microsoft.com/kb/2519277

4) FIX: Visual C++ compilers are removed when you upgrade Visual Studio 2010 Professional or Visual Studio 2010 Express to Visual Studio 2010 SP1 if Windows SDK v7.1 is installed:
http://support.microsoft.com/kb/2519277

5) msvc9compiler.py:尝试使用 VC Express 编译时出现 ValueError:http://bugs.python.组织/issue7511

5) msvc9compiler.py: ValueError when trying to compile with VC Express: http://bugs.python.org/issue7511

推荐答案

最终我能够运行 pip.简而言之(从上面的信息来看是多余的)这是我为 python 3.3 安装 64 位包所做的:

Ultimately I was able to get pip running. In a nutshell (and redundant from info above) here is what I did to intall 64-bit packages for python 3.3:

1) 已安装 Microsoft Visual C++ 2010 Express 在此处下载 (http://www.visualstudio.com/downloads/download-visual-studio-vs)

1) Installed Microsoft Visual C++ 2010 Express Download Here (http://www.visualstudio.com/downloads/download-visual-studio-vs)

2) 安装了 Microsoft SDK 7.1 (Windows 7) (http://www.microsoft.com/en-us/download/details.aspx?id=8279)

2) Installed Microsoft SDK 7.1 (Windows 7) (http://www.microsoft.com/en-us/download/details.aspx?id=8279)

3) 在 SDK 中构建/启用 64 位工具.转到开始菜单并在 Microsoft Windows SDK v7.1 文件夹下,选择 Windows SDK 7.1 命令提示符.一个壳会出现.键入以下命令 setenv/x64.

4) 我安装了一个修复程序(不知道最终是否需要它.)(http://support.microsoft.com/kb/2519277)

4) I installed a fix (don't know if it was ultimately needed.) (http://support.microsoft.com/kb/2519277)

5) 在 C:Program Files (x86)Microsoft Visual Studio 10.0VCinamd64 下创建一个新的 vcvars64.bat 文件.在那个新的批处理文件中,我只包含了一行 CALL "C:Program FilesMicrosoft SDKsWindowsv7.1BinSetEnv.cmd"/x64.我假设这样做是强制 distutils 使用 SDK 中的 C++ 编译器.在此之后正确安装了 Pip.据我了解,C++ 编译器必须与用于编译 python 3.3 的编译器相同.根据我的研究,安装的 SDK 似乎是同一个编译器,但不需要 原始 vcvars64.bat 文件存在.此信息来自:http://www.w7forums.com/threads/vcvarsall-bat-no-64bit-support-vcvars64-bat-missing.6606/.如果我在使用此解决方案的过程中产生问题,请纠正我.谢谢.

5) Created a new vcvars64.bat file under C:Program Files (x86)Microsoft Visual Studio 10.0VCinamd64. Inside of that new batch file I included only the line CALL "C:Program FilesMicrosoft SDKsWindowsv7.1BinSetEnv.cmd" /x64. I am assuming what this does is forces distutils to use the C++ compiler from the SDK. Pip installed correctly after this. As I understand, the C++ compiler has to be the same as that used to compile python 3.3. From my research, it seems that the SDK as installed is that same compiler but just doesn't require that the original vcvars64.bat file be present. This information came from: http://www.w7forums.com/threads/vcvarsall-bat-no-64bit-support-vcvars64-bat-missing.6606/ . Please correct me if I am creating problems down the road with this solution. Thanks.

这篇关于Python PIP 在 Windows 7 上用于 64 位安装的 MS Visual Studio 2010 Express 的路径有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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