user27886 user27886 - 2 months ago 14
Python Question

Cython basic build still failing

I am using python 2.7.6 and am on Windows 7 x64 Here is the entry point display for my python:

Python 2.7.6 (default, Jan 28 2014, 17:59:34) [MSC v.1800 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

So I am using all 32bit binaries. I am trying to compile the fibonacci demo/tutorial from the 2013 Sci Py talk on using Cython showing here. You can download the tutorial files here ( unpack the tutorial files and go into

I have installed Cython using
pip install cython
which is a success. I tried to compile the python

>python build_ext --inplace --compilers=mingw32

running build_ext
Traceback (most recent call last):
File "", line 17, in <module>
ext_modules = exts,
File "C:\Python27\Lib\distutils\", line 151, in setup
File "C:\Python27\Lib\distutils\", line 953, in run_commands
File "C:\Python27\Lib\distutils\", line 972, in run_command
File "C:\Python27\lib\site-packages\Cython\Distutils\", line 163,
in run
File "C:\Python27\Lib\distutils\command\", line 306, in run
File "C:\Python27\Lib\distutils\", line 1004, in new_compiler
return klass(None, dry_run, force)
File "C:\Python27\Lib\distutils\", line 309, in __init__
CygwinCCompiler.__init__ (self, verbose, dry_run, force)
File "C:\Python27\Lib\distutils\", line 152, in __init__
self.dll_libraries = get_msvcr()
File "C:\Python27\Lib\distutils\", line 82, in get_msvcr
raise ValueError("Unknown MS Compiler version %s " % msc_ver)
ValueError: Unknown MS Compiler version 1800

I checked and modified
and saw and made the following changes:

def get_msvcr():
"""Include the appropriate MSVC runtime library if Python was built
with MSVC 7.0 or later.
msc_pos = sys.version.find('MSC v.')
if msc_pos != -1:
msc_ver = sys.version[msc_pos+6:msc_pos+10]
if msc_ver == '1300':
# MSVC 7.0
return ['msvcr70']
elif msc_ver == '1310':
# MSVC 7.1
return ['msvcr71']
elif msc_ver == '1400':
# VS2005 / MSVC 8.0
return ['msvcr80']
elif msc_ver == '1500':
# VS2008 / MSVC 9.0
return ['msvcr90']
elif msc_ver == '1800': # I added this!!!
# VS2013 / MSVC 12.0 # I added this!!!
return ['msvcr120'] # I added this!!!
raise ValueError("Unknown MS Compiler version %s " % msc_ver)

since apparently
msc_ver == '1800'
(the version of msvc my python was compiled with) is the 2013 visual studio c compiler, and reffered to as
from some quick google searches. So I installed that:

enter image description here

Now, however, I get the following cython DLL error.

>python build_ext --compiler=mingw32
running build_ext
failed to import Cython: DLL load failed: A dynamic link library (DLL) initialization routine failed.
error: Cython does not appear to be installed

Where is it looking for the DLL's? What DLL's does it need? Why isn't it finding any the DLL's after installing the 5+ versions of MSVC redistributable packages ( I've struggled with getting python to find msvc compilers in general since day one of using python a good while ago now. true dependency hell. anyway...)

environment variable is set to
, but I don't have
set to anything.

Does anyone have an idea of how to fix this?

what do?

Thank you so much.


So, it looks like something went awry in my installation of python, as user @martineau pointed out. Python 2.7.9 is built using msvc_ver = 1500, or Visual Studio 2008, so why I'd have and older version of Python ( 2.7.6 ) which uses a later compiler is not clear. I tried using a clean 2.7.9 installation on my other computer, and was able to successfully compile, without modifying