python扩展库导入方式中、不推荐使用的是_从C ++应用程序中的嵌入式Python调用时,Numpy导入在多数组扩展库上失败...

在C++应用中嵌入Python时遇到错误,尝试导入numpy多数组扩展模块失败。错误提示可能是因为尝试导入了一个构建失败的numpy版本。问题仅在嵌入环境中出现,而不在解释器中。解决方案是通过dlopen加载libpythonx.x.so并使用RTLD_GLOBAL标志,使符号解析能够找到所需的库。
摘要由CSDN通过智能技术生成

I'm running a C++ application which tries to run python using the https://docs.python.org/3.5/extending/embedding.html function calls. This is the error that the application error message pipes are giving me.

class 'ImportError':

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.

Original error was: /usr/local/lib/python3.5/site-packages/numpy/core/multiarray.cpython-35m-x86_64-linux-gnu.so: undefined symbol: PyExc_UserWarning

I'm quite puzzled as this only occurs when embedding Python in C++ as the import works when I use it through the interpreter. I'm more interested in an answer that adds to my understanding than a quick do this or do that fix. I list some system/problem information below, and some other questions that I'm considering posting about the same topic. Any guidance is appreciated!

System/Problem information:

Ubuntu 16.04, 64 bit

Compiled Python 3.5.5 with enabled-shared

numpy import works in the interpreter (python3.exe, and python3.5.exe)

I have made sure that the PySys_SetPath() sets t

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值