求问各位大佬,下面这个问题如何解决呀?????
问题描述:
1:在qt中创建了一个c++库(libraryDemo.so)用于调用python脚本文件,如下所示:
2:在qt中创建一个c++项目,调用ibraryDemo.so库,可以正常运行出结果:
3:在vscode中调用ibraryDemo.so库运行报错:
错误提示:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/numpy/core/init.py", line 22, in <module>
from . import multiarray
File "/usr/local/lib/python3.8/dist-packages/numpy/core/multiarray.py", line 12, in <module>
from . import overrides
File "/usr/local/lib/python3.8/dist-packages/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: /usr/local/lib/python3.8/dist-packages/numpy/core/_multiarray_umath.cpython-38-x86_64-linux-gnu.so: undefined symbol: PyExc_RecursionError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/numpy/init.py", line 140, in <module>
from . import core
File "/usr/local/lib/python3.8/dist-packages/numpy/core/init.py", line 48, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: /usr/local/lib/python3.8/dist-packages/numpy/core/_multiarray_umath.cpython-38-x86_64-linux-gnu.so: undefined symbol: PyExc_RecursionError
操作系统安装的python和numpy版本:
C#和C++调用的运行环境估计还是有差别的。
https://github.com/numpy/numpy/issues/14946
https://stackoverflow.com/questions/49784583/numpy-import-fails-on-multiarray-extension-library-when-called-from-embedded-pyt
这里有个类似的问题,既然报_multiarray_umath.cpython-38-x86_64-linux-gnu.so这个so的问题,估计某些库的搜索模式有差别
按照这上面的说法改了一下,还是一样的报错耶
so调用要用有个手机的虚拟环境,他是so文件是安卓开发的动态库
嗯???不是很明白
@JoyandJoys: python运行so文件必须要安卓环境结合hook进行调用,不能直接调用,你可以把这so文件简单些一个app中,然后fridahook这个so方法,起服务,调用就好了
@小小咸鱼YwY: 那为什么c++调用就可以正常使用呢???
@JoyandJoys: 很正常啊,so本来就可以用c++运行,只要他so文件不加壳一点问题都没有
@小小咸鱼YwY: 如果我代码里面不用numpy相关的函数,c#也是可以正常通过库访问到python脚本里面,这样就不符合您所说的要加一个壳的步骤呀。
@JoyandJoys: - -,我们说的完全不是一个话题,简单来说python运行 so文件就要安卓环境信不信由你,也不废话
@JoyandJoys: python底层还是c写的,c能调用python,python不一定调用c
@小小咸鱼YwY: 嗯嗯,谢谢您的解答,这个问题已经解决啦