ubuntu20.4中c#通过c++库调用python脚本

求问各位大佬,下面这个问题如何解决呀?????

问题描述:

1:在qt中创建了一个c++库(libraryDemo.so)用于调用python脚本文件,如下所示:
ubuntu20.4中c#通过c++库调用python脚本

2:在qt中创建一个c++项目,调用ibraryDemo.so库,可以正常运行出结果:
ubuntu20.4中c#通过c++库调用python脚本

3:在vscode中调用ibraryDemo.so库运行报错:
ubuntu20.4中c#通过c++库调用python脚本

错误提示:

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:

  • The Python version is: Python3.8 from "/usr/bin/python3"
  • The NumPy version is: "1.19.5"

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版本:
ubuntu20.4中c#通过c++库调用python脚本

回答

问题补充:

我现在怀疑是环境变量的问题,但是不清楚具体是哪里出了问题,这个系统里面的python环境我是用的自带的,只是装了一个python3.8-dev

以上是 ubuntu20.4中c#通过c++库调用python脚本 的全部内容, 来源链接: utcz.com/a/97547.html

回到顶部