C++中的嵌入式python:importerror import numpy.core.multiarray

Embedded python in C++: importerror importing numpy.core.multiarray

本文关键字:import numpy core multiarray importerror 嵌入式 python C++      更新时间:2023-10-16

我正在Visual Studio 2017中开发一个C++程序,该程序应该调用python脚本。我可以在 VS 交互式 python 中导入 numpy,但是在从 main 调用的文件中导入 numpy 时.cpp出现错误

Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

我正在使用Python 3.6,numpy 1.12.0,并在x64调试模式下构建main.cpp。我也在使用Cmake来构建。

我已经搜索了很多,但我找不到可行的解决方案。

我改用boost/python.hpp头文件。虽然我在调试模式下构建我的应用程序,但它没有使用 python 的调试版本。numpy 的导入现在正在工作。