我正在尝试按照本教程使用 pyx、pxd 和 cimport 创建和使用扩展类型。
在终端中编译 Cython 文件时,我收到一个我不知道如何纠正的错误:
cdef class CythonClass:
在 pyx 文件中被指示为错误行。
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
Run Code Online (Sandbox Code Playgroud)
我pip install cython
在 MacOS Sierra 上使用 Cython 版本 .25(并且也尝试过其他版本,每个版本都安装了)。Python 版本是 2.7.10。
按照建议,我安装了 gcc(Xcode 8.2 的命令行工具),但仍然收到错误消息。
文件内容:
像素:
cdef class CythonClass:
cdef:
list list1
dict d1, d2, d3, d4, d5, d6
Run Code Online (Sandbox Code Playgroud)
pyx:
cdef class CythonClass:
def __init__(self):
self.list1 = []
self.d1 = {}
self.d2 = {}
self.d3 = {}
self.d4 = {} …
Run Code Online (Sandbox Code Playgroud)