简体   繁体   English

使用Boost.Python创建的Python模块将不会导入

[英]Python module created with Boost.Python won't be imported

I have a big C++ module with Python 3 bindings using Boost.Python, that I compile to a .so file using CMake on macOS. 我有一个很大的C ++模块,带有使用Boost.Python的Python 3绑定,可以在macOS上使用CMake将其编译为.so文件。

When I try to import it in the REPL, everything seems to work fine: 当我尝试将其导入REPL时,似乎一切正常:

>>>import myModule
>>>

However, as soon as I run the import statement, the famous rocket icon of Python shows up in the Dock and stays there jumping for some minutes and stops after. 但是,一旦我运行import语句,Python的著名火箭图标就会出现在Dock中,并停留在那里跳跃几分钟,然后停下来。 Obviously then, I cannot access any of the functions defined in my module, so the import looks fine but doesn't actually do anything. 显然,那时,我无法访问模块中定义的任何功能,因此导入看起来不错,但实际上不执行任何操作。

I tried looking in the Console and saw that whenever I import myModule , I get two launchservicesd[83]: SecTaskLoadEntitlements failed error=22 . 我尝试在控制台中查看,发现每次import myModule ,都会得到两个launchservicesd[83]: SecTaskLoadEntitlements failed error=22 It brought me to this and that related questions but I can't find what the exact problem is. 它给我带来了这个那个相关的问题,但是我找不到确切的问题是什么。

The C++ module is huge so I just can't look at the code and find the problem, thus I'm asking for any hints about at least how to debug that problem. C ++模块非常庞大,因此我只是无法查看代码并找到问题,因此我希望获得有关至少如何调试该问题的任何提示。

I can suggest the following steps: 我可以建议以下步骤:

  • Try to import that module though local python session. 尝试通过本地python会话导入该模块。 So, run interactive python interpreter, and 'import myModule'. 因此,运行交互式python解释器,然后“导入myModule”。

If bad, try to check: 如果不好,请尝试检查:

  • are python version, with which myMoudle was linked with, is similiar to used interpreter 是与myMoudle链接的python版本,与二手解释器相似
  • check that build architectires are the same 检查建筑设计师是否相同
  • check that you can load even simple boost.python example module 检查您是否可以加载甚至简单的boost.python示例模块

If ok, check that you have correctly set up module search path in your python code. 如果可以,请检查是否已在python代码中正确设置了模块搜索路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM