cython3: Cannot start!
python at mrabarnett.plus.com
Sat Dec 22 14:48:29 EST 2018
On 2018-12-22 18:26, Paulo da Silva wrote:
> Sorry if this is OT.
> I decided to give cython a try and cannot run a very simple program!
> 1. I am using kubuntu 18.04 and installe cython3 (not cython).
> 2. My program tp.pyx:
> # cython: language_level=3
> 3. setup.py
> from distutils.core import setup
> from Cython.Build import cythonize
> ext_modules = cythonize("tp.pyx")
> 4. Running it:
> python3 setup.py build_ext --inplace
> python3 -c 'import tp'
> 5. output:
> ('Test', 2)
> This is wrong for python3! It should output
> Test 2
> It seems that it is parsing tp.pyx as a python2 script!
> I tried to change the print to python2
> print "Test",2
> and it recognizes the syntax and outputs
> Test 2
> So, how can I tell cython to use python3?
> Thanks for any help/comments
Well, I've just tried this on Raspbian with the same files (for Python 3):
python3 -m pip install cython
python3 setup.py build_ext --inplace
python3 -c 'import tp'
and it printed:
More information about the Python-list