I’m trying to follow this tutorial on using pyx, pxd, and cimport to create and use extension types.
When compiling the Cython file in terminal, I am getting an error that I don’t know how to correct for:
cdef class CythonClass:
in the pyx file is indicated as the line of error.
File "/Library/Python/2.7/site-packages/Cython/Build/Dependencies.py", line 1056, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: CythonClass.pyx
I am using Cython version .25 (and have tried other versions as well, each installed with pip install cython
) on MacOS Sierra. Python version is 2.7.10.
As suggested, I installed gcc (Command Line Tools for Xcode 8.2), but am still receiving the error.
File contents:
pxd:
cdef class CythonClass:
cdef:
list list1
dict d1, d2, d3, d4, d5, d6
pyx:
cdef class CythonClass:
def __init__(self):
self.list1 = []
self.d1 = {}
self.d2 = {}
self.d3 = {}
self.d4 = {}
self.d5 = {}
self.d6 = {}
setup.py (invoked by python setup.py build_ext --inplace
in terminal):
from distutils.core import setup
from Cython.Build import cythonize
setup(ext_modules = cythonize(["CythonClass.pyx"]))
At least presently, I'll attempt to compile without using pxd files, since the compilation went through for the extension types. However, the main function that imports the extension types is not compiling (with error: extTypeName is not a type identifier
).