I'm making my first steps with Cython, and I've installed it on my machine according to the instructions in the wiki.
Working through the Cython tutorial I got to pyximport, which is supposed to make cython compilation really simple. When I tried using it, though, I got the following error message (reformatted):
ImportError: Building module failed:
DistutilsPlatformError('
Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.',)
So my question is: anyone know of a way to make pyximport use mingw?
Note that mingw seems to be installed properly, the long way to make Cython modules (using setup.py) did work for me, and that I even created a distutils.cfg
file like the wiki told me.
I was recently mucking around and discovered the setup_args argument of pyximport.install. This works for me:
mingw_setup_args={'options': {'build_ext': {'compiler': 'mingw32'}}}
import pyximport; pyximport.install(setup_args=mingw_setup_args)
maybe this way (from mail list):
c:\Python2x\Lib\distutils\distutils.cfg:
[build]
compiler = mingw32
[build_ext]
compiler = mingw32
You can also create a "pydistutils.cfg" file under your home so that you get either of those paths: "C:\Documents and Settings\YourUsername\pydistutils.cfg" or "C:\Users\YourUsername\pydistutils.cfg".
Then add:
[build_ext]
compiler=mingw32
to that file. Also make sure you have "MinGW"'s gcc on your path. From that point on, when you use "import pyximport; pyximport.install()", cython should generate a folder named ".pyxbld" under your home folder(See Above). On windows, this folder will contain all of the " .c, .o, .pyd, .def" files generated by cython.
Happy cythoning!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With