2

I want to compile my Cython file on Windows 7

python mySetup.py build_ext --inplace

but getting an error

running build_ext building 'sumrange_Cython' extension C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\bin\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\Artem\AppData\Local\Programs\Python\Python36-32\include -IC:\Users\Artem\AppData\Local\Programs\Python\Python36-32\include /Tcsumrange_Cython.c /Fobuild\temp.win32-3.6\Release\sumrange_Cython.obj sumrange_Cython.c c:\users\Artem\appdata\local\programs\python\python36-32\include\pyconfig.h(59): fatal error C1083: Cannot open include file: 'io.h': No such file or directory error: command C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\bin\cl.exe' failed with exit status 2

It seems like problem is in pathes to compiler. I launched the utility located at "C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\"

vcvarsall x86

in order to set up the pathes, but it also fails with the error

Error in script usage. The correct usage is: vcvarsall [option] or vcvarsall [option] store or vcvarsall [option] [version number] or vcvarsall [option] store [version number] where [option] is: x86 | amd64 | arm | x86_amd64 | x86_arm | amd64_x86 | amd64_arm where [version number] is either the full Windows 10 SDK version number or "8.1" to use the windows 8.1 SDK : The store parameter sets environment variables to support store (rather than desktop) development. : For example: vcvarsall x86_amd64 vcvarsall x86_arm store vcvarsall x86_amd64 10.0.10240.0 vcvarsall x86_arm store 10.0.10240.0 vcvarsall x64 8.1 vcvarsall x64 store 8.1 : Please make sure either Visual Studio or C++ Build SKU is installed.

Others have already asked this question but the answer is still absent python pip on Windows - command 'cl.exe' failed

Another way to solve the problem may be is to define the path to another compiler instead of Visual C++ while calling python. But I don't know how to do it.

Community
  • 1
  • 1
Artem Zefirov
  • 353
  • 3
  • 13

1 Answers1

2

Update: Please check this blog post out for a excellent walkthrough: https://andysalerno.com/Compiling-Python https://github.com/andysalerno/old_site_content/blob/master/Compiling-Python.html

I'm not sure why but the Path seems not to be updated. This might be a visual studio 2017 preview feature.

cl.exe resides in C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.10.25017\bin{host}{architecture}\

Try running your commands from the "Developer Command prompt for visual studio 2017 preview" as it knows about this path.

Edit: If you get an error saying "fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'" you need to check this out: https://msdn.microsoft.com/en-us/library/x4d2c09s.aspx?f=255&MSPPError=-2147217396 vcvarsall.bat recides here :C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Auxiliary\Build

Tomas Andersson
  • 144
  • 1
  • 6
  • Wondeful! It works. But is there a way to fix PATH to vs tools or shall I always build Cython sources in this manner? – Artem Zefirov May 03 '17 at 18:57
  • you can always add stuff to PATH manually, but there might be a conflict with the previous version if both exist in the path. So try it out, but maybe note it down somewhere so that you can fix it if you get issues in the future. http://stackoverflow.com/questions/9546324/adding-directory-to-path-environment-variable-in-windows – Tomas Andersson May 04 '17 at 07:20