I was starting to play with cyt开发者_如何学JAVAhon on my windows xp machine configured with Python 2.6. I tried to run the simple example on the Cython site but the conversion of the example .pyx file is immediately failing with a confusing error.
The .pyx file is
def say_hello_to(name):
print("Hello, %s" % name)
setup.py looks like
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [Extension("hello", ["hello.pyx"])]
setup(
name = 'Hello world app',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
In a command window, I execute the command
python setup.py build_ext --inplace
Note that all this is exactly what the webpage says to do.
As a result, I get the following output:
Error converting Pyrex file to C:
--------------------------------------------------------
...
def say_hello_to(name):
^
--------------------------------------------------------
The error message says "Unrecognized characters".
I attempt the same example on a linux box and it works fine.
What is the problem here and why is a colon flagged as being unrecognizable?
(Reposting as an answer because it apparently solved the problem)
Just a guess, but could it be having trouble with line endings? E.g. if the file has Unix '\n'
line endings, but on Windows it's expecting Windows '\r\n'
line endings?
OK, so it was the other way round. It expects '\n'
line endings, and the editor converted them to '\r\n'
.
精彩评论