问题遇到的现象和发生背景
c++调用python numpy库发生异常
问题相关代码,请勿粘贴截图
#include
#include <pybind11/pybind11.h>
#include <pybind11/embed.h>
#include <pybind11/numpy.h>
namespace py = pybind11;
int main()
{
py::scoped_interpreter python;
py::module sys = py::module::import("sys");
py::print(sys.attr("path"));
auto py_append = sys.attr("path").attr("append");
py_append("D:/workspace/workspace/CPBackTest/CPBackTest/PyMode");
py::print(sys.attr("path"));
auto np = py::module::import("numpy");
auto py_mode = py::module::import("python_for_c");
auto res= py_mode.attr("ret_two_add")(1,2);
int ppp = 1;
}