18

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-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.

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).

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.0\VC\bin\amd64 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.)

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.

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) Launching a 64-bit command prompt from Visual Studio 2010

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 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) 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: ValueError when trying to compile with VC Express: http://bugs.python.org/issue7511

Community
  • 1
  • 1
Stacy L. Gardner
  • 561
  • 1
  • 4
  • 12
  • So to clarify: You need a script that's called `vcvarsall.bat`, takes an `amd64` argument, and does the same thing as calling the real `vsvarsall.bat` followed by `setenv /x64`? It seems like you could just create a `vcvarsall.bat` that calls the real one by absolute path, then calls the `setenv`, and put that earlier on your `%PATH%` than the real one / wherever you've configured `pip` to find it instead of your path (as appropriate), and that would solve the problem, right? – abarnert Oct 20 '14 at 20:05
  • As I understand it, pip uses `vcvarsall.bat`. PIP needs various system settings (PATH=, INCLUDE=, LIB=, LIBPATH=). My python is 64-bit and is not finding the system settings that it needs. These settings are set by this batch file when `vcvarsall amd64` is run from command line from its directory. As a second method, it was suggested to create these path statements using MS SDK. It has it's own command line that can be selected from the start menu. 'setenv /x64' is run from that command line. I've read "not to set these path variable manually" so I was trying to fix it as suggested. – Stacy L. Gardner Oct 20 '14 at 20:21
  • Yeah, my point was that you can make a fake `vcvarsall.bat` just so that `pip` can use it. Whether to do so by calling `C:\path\to\real\vcvarsall.bat amd64`, or by calling `C:\path\to\vcvarsall.bat` and then `setenv /x64`, or something different isn't that important; if you know the commands to run to make things work, those are the commands to put in the fake batch file. (I'm posting this as a comment because it's obviously a pretty hacky solution, and hopefully someone has a better one… but I think it should be pretty easy to make work if necessary.) – abarnert Oct 20 '14 at 20:29
  • In trying to figure this out, it seems like vcvarsall keeps coming up in posts in ways that I don't see the relation. It's like it is being used in different ways and the only way that I was trying to use it was to set the appropriate system variables. So I don't think (at this point) that pip needs to be tricked. One error message at a time! – Stacy L. Gardner Oct 20 '14 at 21:06
  • Honestly, I gave up using MSVC to build Python extensions as soon as gcc-mingw could build extensions for VC7 Python builds while VC8 couldn't do so. (I may be a bit off on the version numbers, but you get the idea.) Hopefully someone who still deals with this can help more. But meanwhile, `vcvarsall.bat` is a really simple batch script; if you want to understand what it does, just `type` it, or open it in Notepad. – abarnert Oct 20 '14 at 21:17

4 Answers4

22

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) Installed Microsoft Visual C++ 2010 Express Download Here (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)

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.

4) I installed a fix (don't know if it was ultimately needed.) (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 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.

OYRM
  • 1,395
  • 10
  • 29
Stacy L. Gardner
  • 561
  • 1
  • 4
  • 12
  • 2
    **Step 3** is a no-op. Once you exit the command prompt, the environment variables that it sets stop existing. 1, 2 and 5 are needed, unsure about 4 – Tritium21 Nov 10 '14 at 20:09
  • batch file should be:vcvars64.bat, with an 's'. need vs2010 sp1 too, to get ammintr.h – Hugh Perkins Apr 09 '15 at 14:26
  • 3
    **Step 2** may fail if you already have a version of the VC++ 2010 redistributable installed. This is resolvable by uninstalling the redistributable before SDK installation, reinstall later if necessary. See https://support.microsoft.com/en-us/kb/2717426/de **Step 4** I can confirm that this step is absolutely necessary for 64-bit machines (http://support.microsoft.com/kb/2519277) – OYRM Apr 28 '15 at 16:51
  • 1
    It is important to install the Microsoft SDK 7.1 before the Microsoft Visual C++ 2010 Redistributables. – user2035039 Apr 28 '15 at 17:55
  • Found another possibly useful resource: [https://msdn.microsoft.com/en-us/library/9yb4317s%28v=vs.100%29.aspx](https://msdn.microsoft.com/en-us/library/9yb4317s%28v=vs.100%29.aspx) . – Stacy L. Gardner May 15 '15 at 14:16
  • 3
    You can download MS VC++ 2010 Express here: http://download.microsoft.com/download/1/D/9/1D9A6C0E-FC89-43EE-9658-B9F0E3A76983/vc_web.exe – mab Oct 22 '15 at 11:47
  • Microsoft SDK 7.1 includes Visual C++ 2010 within the installer, is there any reason to install them separately as opposed to letting SDK 7.1 take care of it? – CaffeineConnoisseur Nov 17 '15 at 21:06
  • didn't work for me. did al steps above with reboots after each stage, and uninstalling reinstalling. Still get ValueError: ['path'] when run pip. – clg4 Apr 11 '16 at 18:52
5

For me it was sufficient to perform steps 1, 2 and 5, step 4 was not required:

1) Install Microsoft Visual C++ 2010 (in my case not Express)

2) Install Microsoft SDK 7.1 (Windows 7)

Skip 3 and 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

Done: pip3 install numpy works.

jayesef
  • 751
  • 6
  • 7
1

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).

Hao
  • 43
  • 5
0

Here is what I did to intall 64-bit packages for python 3.4.4 on a windows 10 x64 and x64 based processor:

0)Use precompiled amd64 whl's for everything possible, and the following method for anything that threw errors

1a) Installed Microsoft Visual C++ 2010 Express

1b) Uninstalled Microsoft Visual C++ 2010 Express redistributable via control panel

2) Installed Microsoft SDK 7.1 (Windows 10)

3) I installed fix (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

CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64

5)Running pip install in the SDK command prompt after typing

setenv /x64

and

set DISTUTILS_USE_SDK=1
user27630
  • 102
  • 1
  • 7