Python PIP 在 Windows 7 上用于 64 位安装的 MS Visual Studio 2010 Express 的路径有问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26473854/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python PIP has issues with path for MS Visual Studio 2010 Express for 64-bit install on Windows 7
提问by Stacy L. Gardner
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:
我正在创建一个全新安装的 python 3.3 64 位版本的 virtualenv。(注意:我在我的计算机上安装了几个 python,包括 WinPython,但想为我正在处理的几个项目设置干净和小的虚拟环境。WinPython 版本工作得很好。)当我使用 pip 尝试安装包时,我收到一条错误消息(如果需要,可以包含 pip 日志)。最终,错误消息的最后几行是:
File "c:\python33-b\Lib\distutils\msvc9compiler.py", line 287, in query_vcvarsall raise ValueError(str(list(result.keys())))
ValueError: ['path']
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.
我调查了 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 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).
我花了一些时间在网上研究这个。我发现 MS VS Express 2010 默认安装为 32 位。必须将其设置为 64 位运行(这意味着它将设置上述所需的语句。)显然存在一个错误,并且此版本未安装 64 位工具。所以我安装了 MS SDK 以安装 64 位工具。然后我发现有一个修复程序并安装了它(在下面的链接中列出)。
There were several methods outlined to create the paths for the 64-bit VS. One was to run vcvarsall amd64on 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.0\VC\bin\amd64directory. 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.)
概述了为 64 位 VS 创建路径的几种方法。一种是vcvarsall amd64在 MS VS 的命令行上运行。这导致出现一条消息,指出我的计算机上未安装这些工具。这些工具将驻留在C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64目录中。它显然正在寻找的文件是 vcvars64.bat (或类似的东西)。我有目录但没有批处理文件。(有人建议使用 x86_amd64 方法,但它有所有相同的问题。)
The second recommendation was to run setenv /x64from 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.
第二个建议是setenv /x64从 SDK 命令行运行。我运行了它,它似乎运行正确。但是,当我尝试通过 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.
我的问题最终是如何让 pip 顺利运行?只是提一下,是的,在每次安装后再次测试 pip 并尝试修复此问题之前,我确实重新启动了。
Here are some sites that helped me get this far:
以下是一些帮助我走到这一步的网站:
1) Launching a 64-bit command prompt from Visual Studio 2010
1)从 Visual Studio 2010 启动 64 位命令提示符
2) Setting the Path and Environment Variables for MS VS 2010 Command-Line Builds:
http://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx
2) 为 MS VS 2010 命令行构建设置路径和环境变量:http:
//msdn.microsoft.com/en-us/library/f2ccy3wt.aspx
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
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
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
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
5) msvc9compiler.py: ValueError when trying to compile with VC Express: http://bugs.python.org/issue7511
5) msvc9compiler.py: 尝试用 VC Express 编译时出现 ValueError: http://bugs.python.org/issue7511
采纳答案by Stacy L. Gardner
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:
最终我能够让 pip 运行。简而言之(从上面的信息来看是多余的)这是我为 python 3.3 安装 64 位包所做的:
1) Installed Microsoft Visual C++ 2010 Express Download Here(http://www.visualstudio.com/downloads/download-visual-studio-vs)
1)在此处安装 Microsoft Visual C++ 2010 Express下载( http://www.visualstudio.com/downloads/download-visual-studio-vs)
2) Installed Microsoft SDK 7.1 (Windows 7) (http://www.microsoft.com/en-us/download/details.aspx?id=8279)
2) 安装 Microsoft SDK 7.1 (Windows 7) ( http://www.microsoft.com/en-us/download/details.aspx?id=8279)
3) Built/enabled the 64-bit tools in SDK. Go to start menu and under Microsoft Windows SDK v7.1 folder, select Windows SDK 7.1 Command Prompt. A shell will come up. Type the following command setenv /x64.
3) 在 SDK 中构建/启用 64 位工具。转到开始菜单并在 Microsoft Windows SDK v7.1 文件夹下,选择 Windows SDK 7.1 命令提示符。一个壳会出现。键入以下命令setenv /x64。
4) I installed a fix (don't know if it was ultimately needed.) (http://support.microsoft.com/kb/2519277)
4)我安装了一个修复程序(不知道最终是否需要它。)(http://support.microsoft.com/kb/2519277)
5) Created a new vcvars64.bat file under C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64. Inside of that new batch file I included only the line CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.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 originalvcvars64.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.
5) 在 C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 下创建一个新的 vcvars64.bat 文件。在那个新的批处理文件中,我只包含了CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.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/。如果我在使用此解决方案的过程中产生问题,请纠正我。谢谢。
回答by jayesef
For me it was sufficient to perform steps 1, 2 and 5, step 4 was not required:
对我来说,执行步骤 1、2 和 5 就足够了,不需要步骤 4:
1) Install Microsoft Visual C++ 2010 (in my case not Express)
1) 安装 Microsoft Visual C++ 2010(在我的情况下不是 Express)
2) Install Microsoft SDK 7.1 (Windows 7)
2) 安装 Microsoft SDK 7.1 (Windows 7)
Skip 3 and 4.
跳过 3 和 4。
5) Create C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat containing the line CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
5) 创建 C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat 包含 CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.bat 行。 cmd" /x64
Done: pip3 install numpy works.
完成: pip3 install numpy 工作。
回答by Hao
The 5th step did not work for me (I am using VC++ 10 Express). I finally got pip working by running pip install in the SDK command prompt after typing setenv /x64 (running pip in the normal cmd.exe prompt did not work).
第 5 步对我不起作用(我使用的是 VC++ 10 Express)。输入 setenv /x64 后,我终于通过在 SDK 命令提示符下运行 pip install 使 pip 正常工作(在正常的 cmd.exe 提示符下运行 pip 不起作用)。
回答by user27630
Here is what I did to intall 64-bit packages for python 3.4.4 on a windows 10 x64 and x64 based processor:
这是我在基于 Windows 10 x64 和 x64 的处理器上为 python 3.4.4 安装 64 位包所做的工作:
0)Use precompiled amd64 whl's for everything possible, and the following method for anything that threw errors
0) 对所有可能的情况使用预编译的 amd64 whl,对任何抛出错误的情况使用以下方法
1a) Installed Microsoft Visual C++ 2010 Express
1a) 已安装 Microsoft Visual C++ 2010 Express
1b) Uninstalled Microsoft Visual C++ 2010 Express redistributable via control panel
1b) 通过控制面板卸载 Microsoft Visual C++ 2010 Express 可再发行版
2) Installed Microsoft SDK 7.1 (Windows 10)
2) 已安装 Microsoft SDK 7.1 (Windows 10)
3) I installed fix (http://support.microsoft.com/kb/2519277)
3)我安装了修复程序(http://support.microsoft.com/kb/2519277)
4) Created a new vcvars64.bat file under C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 including only the line
4) 在 C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 下创建了一个新的 vcvars64.bat 文件,仅包括该行
CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
5)Running pip install in the SDK command prompt after typing
5)输入后在SDK命令提示符下运行pip install
setenv /x64
and
和
set DISTUTILS_USE_SDK=1

