seit 2 Tagen versuche ich der Cython-Fehlermeldung:
Code: Alles auswählen
ValueError: hermelin.app.ng_huc.htrees.Ngram has the wrong size, try recompiling
Um den obigen Fehler einzugrenzen habe ich folgendes Test-Projekt geschrieben:
node.pxd
Code: Alles auswählen
cdef class Node:
cdef public str name
cdef public Node left
cdef public Node right
Code: Alles auswählen
cdef class Node:
def __init__(self, name):
self.name = name
Code: Alles auswählen
cimport node
from node cimport Node
cpdef Node test():
obj = Node("foo")
obj.left = Node("bar")
obj.right = Node("egg")
return obj
Code: Alles auswählen
"""
Eine einfache Setup-Datei
"""
__revision__ = 0.1
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
ext_modules=[
Extension(
"work",
sources=["node.pyx", "work.pyx"],
)
]
setup(
name = "work",
ext_modules = cythonize(ext_modules)
)
Code: Alles auswählen
#!/usr/bin/env python3
import work
print(work.test())
Code: Alles auswählen
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./test.py", line 4, in <module>
import work
File "/home/albert/test/test.py", line 4, in <module>
import work
File "test/node.pxd", line 1, in init test.work (work.c:906)
cdef class Node:
ImportError: No module named 'test.node'; 'test' is not a package
Wo liegt hier mein Denkfehler! Freue mich über jede Hilfe und bedanke mich schon mal im Voraus.
Update: Entschuldigung habe vergessen zu erwähnen das ich die setup.py mit folgendem Befehl starte:
Code: Alles auswählen
./setup.py build_ext --inplace