4

I'm tearing my hair out trying to compile c though Python's distutils. Specifically I'm trying to get started with Cython following this guide: http://docs.cython.org/src/quickstart/build.html, using a setup.py.

I'm running Python 3.5.0 under Anaconda 2.4.0 (64-bit), Windows 7.

I get the Unable to find vcvarsall.bat error referred to here: Cannot find vcvarsall.bat when running a Python script and in various other questions.

None of the proposed solutions work for me. So far I have tried:

  • installing Visual Studio - I have all versions from 2008 to 2013, ie 9.0, 10.0, 11.0, and 12.0.
  • pointing environment variables (VS100COMNTOOLS etc) related to the above directly to the correct locations
  • installing Microsoft Visual C++ Compiler for Python (as above link). This seemed to work but I get a compilation error that seems to be an incompatibility; I think because the compiler is intended for Python 2.7.
  • Ravi Kumar's suggestion at the above link to update pip's setuptools. Pip gave me an error saying it couldn't update.
  • Installing MS Windows SDK for Windows 7 and .NET Framework 4 as https://github.com/cython/cython/wiki/CythonExtensionsOnWindows. The final step failed with an error message that the x64 compilers aren't currently installed.

The only thing I can think of is installing MinGW which I've seen suggested in some places, but that CythonExtensionsOnWindows link specifically recommended against it.

Any other suggestions would be very welcome! In particular, since I clearly have all the versions of VS I could possibly need, is there a way to force Python to recognise them, other than setting environment variables VS100COMNTOOLS or similar?

Interestingly conda does seem to recognise the installed compilers, as a separate pip install attempt that failed with this same error, worked with conda.

Community
  • 1
  • 1
Giswok
  • 559
  • 5
  • 16

1 Answers1

2

As it turns out, Python 3.5 needs Visual Studio 2015. Advice elsewhere on fixing this for other Python versions is outdated.

Get Visual Studio 2015 Community here: https://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs.aspx, this worked for me with no further steps needed.

Many thanks to Ionel, apparently the only place on the web to find this information! http://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/

Giswok
  • 559
  • 5
  • 16
  • Does it really need the Studio? In my list of programs I only see Microsoft Visual C++ 2017... (which my pip install can't find as well, just as in this question) – zwep Sep 21 '17 at 15:22