PYIMPORT_IMPORTMODULE永远不会返回

发布于 2025-02-13 01:27:31 字数 340 浏览 0 评论 0原文

我实际上是C ++程序员,不得不使用PYBIND11在我的应用程序中运行一些Python代码。一切都很好,但是突然间,我不再可以使用:“ Pyimport_importModule(const char *name)”导入一些Python库。 而导入“系统”和其他人的工作正常,例如导入“ numpy”在该功能中导致永不返回。 不过,使用python命令行效果很好。 上个月发生的唯一变化是我升级为Win10。 重新安装“ numpy”无济于事。

那么,我该如何解决呢?

编辑:相关代码行是:

PyObject *obj = PyImport_ImportModule("numpy");

I'm actually a c++ programmer and had to use pybind11 to get some python code run in my application. Everything was fine, but suddenly I no longer can import some of my python libraries using: 'PyImport_ImportModule(const char *name)'.
Whereas importing 'sys' and others works fine, for example importing 'numpy' results in the function never return.
Using the python command line with 'numpy' works fine, though.
The only thing that changed in the last month was that I upgraded to Win10.
Reinstalling 'numpy' did not help.

So, how could I solve this?

edit: the relevant code line is:

PyObject *obj = PyImport_ImportModule("numpy");

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文