Cython编译器-致命错误C1083:无法打开包含文件



我按照以下步骤复制了使用状态空间模型的古典音乐作曲代码。

此代码的推理算法在Cython中。要运行笔记本,首先运行:

np.get_include(),输出一个采样路径。

则,在终端集export CFLAGS="-I sample-path $CFLAGS"中。我用了Windows等效的:

set CFLAGS = "-IC:\Users\scvan\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy\core\include%CFLAGS%"

最后,在终端中运行

python setup.py build_ext --inplace

然而,当我尝试运行build_ext命令时,我一直得到以下错误:

building 'BaumWelch' extension
"C:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.32.31326binHostX86x64cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD "-IC:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0include" "-IC:Program FilesWindowsAppsPythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0Include" "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.32.31326ATLMFCinclude" "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.32.31326include" "-IC:Program Files (x86)Windows Kits10include10.0.22000.0ucrt" "-IC:Program Files (x86)Windows Kits10\include10.0.22000.0\shared" "-IC:Program Files (x86)Windows Kits10\include10.0.22000.0\um" "-IC:Program Files (x86)Windows Kits10\include10.0.22000.0\winrt" "-IC:Program Files (x86)Windows Kits10\include10.0.22000.0\cppwinrt" /TcBaumWelch.c /Fobuildtemp.win-amd64-cpython-310ReleaseBaumWelch.obj
BaumWelch.c
BaumWelch.c(711): fatal error C1083: Cannot open include file: 'numpy/arrayobject.h': No such file or directory
error: command 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX86\x64\cl.exe' failed with exit code 2

据我所知,我已经在Visual Studio中安装了所有正确的构建工具。也许我使用了错误的Windows等效的出口CFLAGS,有人能帮助我吗?

我通过将include_dirs = [numpy.get_include()]添加到setup.py文件中来解决这个问题:

from distutils.core import setup
from Cython.Build import cythonize
import numpy
setup(
name = 'Baum Welch Code',
ext_modules = cythonize("BaumWelch.pyx"),
include_dirs = [numpy.get_include()]
)

相关内容

  • 没有找到相关文章

最新更新