12

I'm trying getting the following errors while trying to install/compile ctools for python (version info)

ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:22:14) [MSC v.1500 64 bit (AMD64)] on win32
  • OS: Windows 7 Professional 64-bit (Service Pack 1)
  • Installed: Microsoft Visual C++ 2008 Express Edition

Error:

building 'deap.cTools' extension
Traceback (most recent call last):
  File "setup.py", line 40, in <module>
    cmdclass = {'build_py': build_py}
  File "C:\Python27\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\distutils\command\install.py", line 563, in run
    self.run_command('build')
  File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\distutils\command\build.py", line 127, in run
    self.run_command(cmd_name)
  File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\distutils\command\build_ext.py", line 340, in run
    self.build_extensions()
  File "C:\Python27\lib\distutils\command\build_ext.py", line 449, in build_extensions
    self.build_extension(ext)
  File "C:\Python27\lib\distutils\command\build_ext.py", line 499, in build_extension
    depends=ext.depends)
  File "C:\Python27\lib\distutils\msvc9compiler.py", line 473, in compile
    self.initialize()
  File "C:\Python27\lib\distutils\msvc9compiler.py", line 383, in initialize
    vc_env = query_vcvarsall(VERSION, plat_spec)
  File "C:\Python27\lib\distutils\msvc9compiler.py", line 299, in query_vcvarsall
    raise ValueError(str(list(result.keys())))
ValueError: [u'path']

I've installed PyWin as suggested in here, but it didn't help. I'd appreciate help sorting out this issue.

Edit

Same issue arises when trying to install scikit-learn

  File "C:\Python27\lib\distutils\msvc9compiler.py", line 299, in query_vcvarsall
    raise ValueError(str(list(result.keys())))
ValueError: [u'path']
Community
  • 1
  • 1
Olumide
  • 5,397
  • 10
  • 55
  • 104
  • this might help you http://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat – namit Nov 28 '12 at 02:43
  • @kuyan: (1) I've already installed Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 without setting the variables (2) I can't find setenv on my machine (3) My promot isn't yellow. – Olumide Nov 28 '12 at 22:37
  • ... Note that I trying to build a module and not python. – Olumide Nov 28 '12 at 22:45

5 Answers5

21

I summarized above in my blog. http://springflex.blogspot.com/2014/02/how-to-fix-valueerror-when-trying-to.html

To install Visual Studio 2008 Express Edition with all required components:

  1. Install Microsoft Visual Studio 2008 Express Edition. The main Visual Studio 2008 Express installer is available from (the C++ installer name is vcsetup.exe):

  2. Install the Microsoft Windows SDK. The Microsoft Windows SDK is available by searching Microsoft's download site, or by going directly to: http://www.microsoft.com/downloads/details.aspx?FamilyId=F26B1AA4-741A-433A-9BE5-FA919850BDBF&displaylang=en

  3. To verify that you have all installed components, check that the Microsoft SDK contains the "amd64" version of the C/C++ compiler "cl.exe". This is usually installed into

    C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\cl.exe
    
  4. copy .../VC/bin/vcvars64.bat to .../VC/bin/vcvarsamd64.bat

  5. copy .../VC/bin/vcvars64.bat to .../VC/bin/amd64/vcvarsamd64.bat

patricus
  • 59,488
  • 15
  • 143
  • 145
user2276550
  • 283
  • 2
  • 3
18

Since you're using the 64 bit version of Python, once you have installed Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 (which installs the 64bit compiler that isn't installed when installing Visual Studio 2008 SP1 Express Edition); You need to copy the vcvars64.bat to a location where vcvarsall.bat claims it to be.

From %CSIDL_PROGRAM_FILESX86%\Microsoft Visual Studio 9.0\VC\bin\, you need to copy vcvars64.bat to amd64\vcvarsamd64.bat.

Note the amd part in the destination file name.

PAT
  • 507
  • 5
  • 13
  • the solution is actually the same as provided below by user2276550 but instead of using Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1, he uses Windows SDK for Windows Server 2008 and .NET Framework 3.5. The problem is that your solution doesn't work unless I do "copy .../VC/bin/vcvars64.bat to .../VC/bin/vcvarsamd64.bat" as illustrated the 4th step of user2276550's post. Is that a missing step? – Kevin Q Jun 03 '15 at 12:54
  • If anyone is worried about trying to find a newer .NET framework SDK, don't worry. I already had 4.6.1 installed but I went ahead and installed 3.5 as instructed here, copied the files, and it fixed the issue. – rleelr May 17 '16 at 13:14
1

Microsoft now publishes a Visual C++ compiler just for Python 2.7, although it will work for other versions of Python that used the same compiler. Check the system requirements: setuptools 6.0 or later is required. It will not work with packages using distutils.

Don Kirkby
  • 53,582
  • 27
  • 205
  • 286
0

I experienced this issue because I did not have the 64-bit version of Visual C++ 2008. To solve the issue, I installed it through Change/Remove in Programs and Features, following this answer.

Community
  • 1
  • 1
1''
  • 26,823
  • 32
  • 143
  • 200
0

I had this same problem, but just renaming the files listed above (in a somewhat opaque way) didn't work for me. What did work is a much easier solution. Just run vcvarsall.bat before you start the install. This sets the correct paths and is much easier to understand. In my case, I needed a 64 bit build so I ran: "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64

Corwin Joy
  • 645
  • 7
  • 14