这是我学习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
如何解决此问题?