when use cython to create helloworld.c from helloworld.pyx , this error occured:
error compiling Cython file:
-------------------------------------------
I don't know if this is still relevant, but in my case, with cython 0.23, to compile Python3 code you have to pass the flag -3
. For example
cython -3 mycode.py
Cython is defaulting to Python 2 semantics. Set the language level to 3, which can be done with the following comment:
#cython: language_level=3
ref: https://cython.readthedocs.io/en/stable/src/reference/compilation.html#compiler-directives
It looks like cython treats all prints as python 2 statements by default. In order to use the python 3 print function you need to import it from the future module:
from __future__ import print_function
print('hello world',end='')