cython 0.23.4, py 3.5.0, MacOSX 10.8.5

93 views
Skip to first unread message

Alex Martelli

unread,
Nov 23, 2015, 2:01:57 PM11/23/15
to cython-users
I have a trivial "hello world" Cython module working just fine w/Python 2.7 on my Mac, w/setup.py being:

from distutils.core import setup
from Cython.Build import cythonize

setup(name="hello",ext_modules=cythonize('hello.pyx'))

However on installing cython for Python 3.5 (with `pip3 install cython`, seems fine, downloads and installs Cython-0.23.4-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl), then `sudo python3 setup.py install` on this trivial module crashes:

Traceback (most recent call last):
  File "setup.py", line 2, in <module>
    from Cython.Build import cythonize
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/Cython/Build/__init__.py", line 1, in <module>
    from .Dependencies import cythonize
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/Cython/Build/Dependencies.py", line 49, in <module>
    from ..Compiler.Main import Context, CompilationOptions, default_options
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/Cython/Compiler/Main.py", line 28, in <module>
    from .Scanning import PyrexScanner, FileSourceDescriptor
ImportError: dynamic module does not define module export function (PyInit_.Scanning)

Cython bug, or, am I doing something wrong? I'd love to cover Cython better in the 3rd ed of Python in a Nutshell (which I'm writing at long last), but if I can't test with Python 3.5 (which the book will cover as well as 2.7), then I may need to rethink the strategy.


Thanks,

Alex

Chris Barker

unread,
Nov 23, 2015, 9:31:12 PM11/23/15
to cython-users
Alex,

Something is up, but it's not inherent to Cython and py3.5.

I just duplicated almost exactly what you did, and it works fine.

This is such a trivial example, it doesn't test much, but the basics are there.

I used Python3.5 from Anaconda, and cython installed by conda:

$ python --version
Python 3.5.0 :: Continuum Analytics, Inc.

$ cython --version
Cython version 0.23.4

Running on OS-X 10.11.1 recently installed from scratch. Totally stock except for Anaconda (actually, miniconda, with only a few packages intsalled)

(as a side note, I didn't do anything special at all to install the compiler!)

As for why it doesn't work for you -- total mystery there!



However on installing cython for Python 3.5 (with `pip3 install cython`, seems fine, downloads and installs Cython-0.23.4-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl), then

you might try disabling wheels and installing form source (or try conda :-) )

 
`sudo python3 setup.py install` on this trivial module crashes:

I'd also be careful about sudo and instal when testing. I did:

python setup.py build_ext --inplace

though I can't imagine that has anythign to do with this issue.
 
Traceback (most recent call last):
  File "setup.py", line 2, in <module>
    from Cython.Build import cythonize
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/Cython/Build/__init__.py", line 1, in <module>
    from .Dependencies import cythonize
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/Cython/Build/Dependencies.py", line 49, in <module>
    from ..Compiler.Main import Context, CompilationOptions, default_options
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/Cython/Compiler/Main.py", line 28, in <module>
    from .Scanning import PyrexScanner, FileSourceDescriptor
ImportError: dynamic module does not define module export function (PyInit_.Scanning)
 
Cython bug, or, am I doing something wrong?

It looks like this is failing when trying to "cythonize" -- it hasn't even gotten to running cython itself. So looks like a build error of some sort. I'm not sure who built those wheels, but I'd try a source install next.

I'd love to cover Cython better in the 3rd ed of Python in a Nutshell (which I'm writing at long last),

Awesome!
 
but if I can't test with Python 3.5 (which the book will cover as well as 2.7), then I may need to rethink the strategy.

you'll get it to work :-)

-Chris

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris....@noaa.gov
setup.py
hello.pyx

Chris Barker - NOAA Federal

unread,
Nov 24, 2015, 11:17:39 AM11/24/15
to cython-users

It looks like this is failing when trying to "cythonize" -- it hasn't even gotten to running cython itself.

Another debugging technique is to take cythonize out of the equation -- can you run Cython itself:

$ cython test_file.pyx

And if you pass the name of the generated c file to Extension() in your setup.py it should build.

cythonize() makes it a bit easier, and gives you better make-like functionality, but it's not required.

HTH,
  -CHB



So looks like a build error of some sort. I'm not sure who built those wheels, but I'd try a source install next.

I'd love to cover Cython better in the 3rd ed of Python in a Nutshell (which I'm writing at long last),

Awesome!
 
but if I can't test with Python 3.5 (which the book will cover as well as 2.7), then I may need to rethink the strategy.

you'll get it to work :-)

-Chris

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris....@noaa.gov
<setup.py>
<hello.pyx>
Reply all
Reply to author
Forward
0 new messages