when use cython to create helloworld.c from helloworld.pyx , this error occured:
error compiling Cython file:
------------------------------------------------------------
...
print('hello world',end='')
^
------------------------------------------------------------
p21.pyx:1:23: Expected ')', found '='
my command to create helloworld.c is:
cython3 --embed p21.pyx
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='')
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