cython error compiling with print function parameters

前端 未结 3 497
别那么骄傲
别那么骄傲 2021-01-04 01:00

when use cython to create helloworld.c from helloworld.pyx , this error occured:

    error compiling Cython file:
-------------------------------------------         


        
相关标签:
3条回答
  • 2021-01-04 01:21

    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
    
    0 讨论(0)
  • 2021-01-04 01:22

    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

    0 讨论(0)
  • 2021-01-04 01:40

    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='')
    
    0 讨论(0)
提交回复
热议问题