Error al intentar compilar el ejemplo básico de la extensión de python (windows)

I have Python 2.6 and Visual Studio 2008 running on a Win7 x64 machine. When I try to build the basic python extension example in c "example_nt" as found in the python 2.6 sources distribution, it fails:

python setup.py build

And this results in:

running build
running build_ext
building 'aspell' extension
Traceback (most recent call last):
  File "setup.py", line 7, in <module>
    ext_modules = [module1])
  File "C:\Python26\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "C:\Python26\lib\distutils\dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
    cmd_obj.run()
  File "C:\Python26\lib\distutils\command\build.py", line 134, in run
    self.run_command(cmd_name)
  File "C:\Python26\lib\distutils\cmd.py", line 333, in run_command
    self.distribution.run_command(command)
  File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
    cmd_obj.run()
  File "C:\Python26\lib\distutils\command\build_ext.py", line 343, in run
    self.build_extensions()
  File "C:\Python26\lib\distutils\command\build_ext.py", line 469, in build_extensions
self.build_extension(ext)
  File "C:\Python26\lib\distutils\command\build_ext.py", line 534, in build_extension
depends=ext.depends)
  File "C:\Python26\lib\distutils\msvc9compiler.py", line 448, in compile
self.initialize()
  File "C:\Python26\lib\distutils\msvc9compiler.py", line 358, in initialize
    vc_env = query_vcvarsall(VERSION, plat_spec)
  File "C:\Python26\lib\distutils\msvc9compiler.py", line 274, in query_vcvarsall
raise ValueError(str(list(result.keys())))
ValueError: [u'path']

What can I do to fix this? Any help will be appreciated

preguntado el 08 de enero de 11 a las 19:01

Make sure you are running from the "Visual Studio Command Prompt" that has the appropriate environmental variables set, and that the version of Python you are using matches the bit-ness (32/64) of the compiler. -

Este es un duplicado de stackoverflow.com/questions/4624507 -

2 Respuestas

For Win7 x64 machine Python 2.6 (x64) machine, you need to install
SDK de Microsoft Windows para Windows 7 y .NET Framework 3.5 SP1
See the instructions at
http://wiki.cython.org/64BitCythonExtensionsOnWindows

The commercial Visual Studio 2008 is for Python 2.6, 2.7 and 2.8 on the 32-bit x86 setup.

Respondido el 01 de diciembre de 11 a las 23:12

I would avoid installing the Windows SDK and VS 2008 for this.

I believe the problem you have is due to VS 2008 not having the 64-bit compilers. To check this, find your directory containing vcvarsall.bat (search in the VS 2008 directory for it C:\Program Files (x86)\Microsoft Visual Studio 9.0). Once you've found vcvarsall.bat, open a cmd prompt in the directory it's in and type .\vcvarsall.bat amd64 If it is not the problem, you will see Setting environment for using Microsoft Visual Studio 2008 x64 tools. If this is the problem, you will get back a message saying something about configuration. This is easy to fix.

The express version of VS does not have the 64-bit compilers. The solution is to also install the SDK but is messy and unreliable so MS have provided all the compilers together in a single download: http://www.microsoft.com/en-gb/download/details.aspx?id=44266

Once you have downloaded the compilers, you can follow my post here if it doesn't work straight out the box: pyusb 2.7 windows install error

contestado el 23 de mayo de 17 a las 15:05

Tenga en cuenta que No se recomiendan las respuestas de solo enlace., Las respuestas de SO deben ser el punto final de la búsqueda de una solución (frente a otra escala más de referencias, que tienden a volverse obsoletas con el tiempo). Considere agregar una sinopsis independiente aquí, manteniendo el enlace como referencia. - kleopatra

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.