From: JR on
Hello All,

I was hoping I could get some help with this issue with getting Cython
to work. Earlier I had an issue that said "unable to find
vcvarsall.bat" and it turns out there is an active bug report that
covers that issue (I have a 64 bit windows system). I still hadn't
installed 3.1.2, so I did that tonight and now I have the issue below.
Any thoughts on what I am doing wrong?



Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\James>cd C:\Python31

C:\Python31>python setup.py build_ext --inplace
running build_ext
cythoning hello.pyx to hello.c

Error converting Pyrex file to C:
------------------------------------------------------------
....
def say_hello_to(name):
^
------------------------------------------------------------

C:\Python31\hello.pyx:1:23: Unrecognized character
building 'hello' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python31\include -
IC:\Pytho
n31\PC -c hello.c -o build\temp.win-amd64-3.1\Release\hello.o
hello.c:1:2: #error Do not use this file, it is the result of a failed
Cython co
mpilation.
error: command 'gcc' failed with exit status 1

C:\Python31>
From: Stefan Behnel on
JR, 24.03.2010 03:51:
> I was hoping I could get some help with this issue with getting Cython
> to work. Earlier I had an issue that said "unable to find
> vcvarsall.bat" and it turns out there is an active bug report that
> covers that issue (I have a 64 bit windows system). I still hadn't
> installed 3.1.2, so I did that tonight and now I have the issue below.
> Any thoughts on what I am doing wrong?
>
>
> Microsoft Windows [Version 6.1.7600]
> Copyright (c) 2009 Microsoft Corporation. All rights reserved.
>
> C:\Users\James>cd C:\Python31
>
> C:\Python31>python setup.py build_ext --inplace
> running build_ext
> cythoning hello.pyx to hello.c
>
> Error converting Pyrex file to C:
> ------------------------------------------------------------
> ...
> def say_hello_to(name):
> ^
> ------------------------------------------------------------
>
> C:\Python31\hello.pyx:1:23: Unrecognized character

Given that you're on Windows, this looks like a known bug in Cython:

http://trac.cython.org/cython_trac/ticket/520

This is due to the lack of universal newline support in the codecs module,
which has been fixed in the new Py2.6+ 'io' module. A patch for Cython that
switches to the new 'io' module and works around this issue in older Python
versions is available:

http://hg.cython.org/cython-devel/raw-rev/751bdd38b55c

That being said, the simplest way to work around this issue is to switch to
Unix line endings in your source file. Most editors support this without
problems.

Stefan