2

这是我学习sklearn的问题。sklearn 中有一些 cython 代码,例如:

 sklearn/tree/
     _utils.pyd
     _tree.pyd
     _test.pyx

包含_test.pyx代码:

   from ._utils cimport log

现在我想通过使用 Cython 来遵守_test.pyx_test.pyd但它不起作用,错误是:

Error compiling Cython file:
------------------------------------------------------------
...

import numpy as np
cimport numpy as np
np.import_array()

from ._utils cimport log
^
------------------------------------------------------------

sklearn\tree\_test.pyx:30:0: 'sklearn\tree\_utils.pxd' not found

这是我的编译代码cythonbuild.py

from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
import numpy 

extensions = [
    Extension("tree", ["_criterion.pyx"],
        include_dirs = [numpy.get_include()],
)
]
setup(
    name = "test",
    ext_modules = cythonize(extensions),
)

然后我在cmd中运行命令:

python cythonbuild build_ext --inplace

我该如何解决这个问题?

4

0 回答 0