1

I'm trying to wrap a c++ code into python using cython. my .py code for this is

from distutils.core import setup
from Cython.Build import cythonize
setup(
    ext_modules=cythonize("helloworld.pyx"),
    )

however while compling it with

python setup.py build_ext --inplace

I get an error

running build_ext
building 'helloworld' extension
Traceback (most recent call last):
  File "setup.py", line 4, in <module>
    ext_modules=cythonize("helloworld.pyx"),
  File "C:\Python34\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Python34\lib\distutils\command\build_ext.py", line 339, in run
    self.build_extensions()
  File "C:\Python34\lib\distutils\command\build_ext.py", line 448, in build_extensions
    self.build_extension(ext)
  File "C:\Python34\lib\distutils\command\build_ext.py", line 503, in build_extension
    depends=ext.depends)
  File "C:\Python34\lib\distutils\msvc9compiler.py", line 460, in compile
    self.initialize()
  File "C:\Python34\lib\distutils\msvc9compiler.py", line 371, in initialize
    vc_env = query_vcvarsall(VERSION, plat_spec)
  File "C:\Python34\lib\distutils\msvc9compiler.py", line 287, in query_vcvarsall
    raise ValueError(str(list(result.keys())))
ValueError: ['path']

I am working on visual studio 2010. I am kind of aware this error is because of vcvars6.bat but I don"t know how to fix it. please help

Payal Singh
  • 131
  • 1
  • 1
  • 7

1 Answers1

2

It looks like you are running 64-bit. Visual Studio 2010 is only the right choice if you are using Python 3.3 or 3.4.

I would guess you don't have the compiler set up properly. In the Python 3.4 section Ionel's Codelog discusses the proper order of installation (VC++ 2010, Windows SDK for VS 2010, .NET 4.0, create a fake vcvars64.bat file, apply VC 2010 SP1, apply VC++ 2010 SP1.

Alternately, you can also try setting some environmental variables as described at the bottom of the Python 3.4 section in Ionel's Codelog post.

I'm guessing you got the versions wrong, the order wrong, or skipped the fake .bat file or the environmental variables.

Casey
  • 475
  • 6
  • 19