Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么PyImport_在python 3.7.2中导入模块segfault?_Python_C++_Python 3.7 - Fatal编程技术网

为什么PyImport_在python 3.7.2中导入模块segfault?

为什么PyImport_在python 3.7.2中导入模块segfault?,python,c++,python-3.7,Python,C++,Python 3.7,c api中的python导入是否会导致其他人出现错误 #0 0x00007ffff7d7efc4 in PyUnicode_InternInPlace () from /usr/lib64/libpython3.7m.so.1.0 #1 0x00007ffff7d7f00e in PyUnicode_InternFromString () from /usr/lib64/libpython3.7m.so.1.0 #2 0x00007ffff7d2fb88 in PyImport_Impo

c api中的python导入是否会导致其他人出现错误

#0  0x00007ffff7d7efc4 in PyUnicode_InternInPlace () from /usr/lib64/libpython3.7m.so.1.0
#1  0x00007ffff7d7f00e in PyUnicode_InternFromString () from /usr/lib64/libpython3.7m.so.1.0
#2  0x00007ffff7d2fb88 in PyImport_Import () from /usr/lib64/libpython3.7m.so.1.0
#3  0x00007ffff7d347bb in PyImport_ImportModule () from /usr/lib64/libpython3.7m.so.1.0
#4  0x00000000004005f0 in main () at test2.cpp:5

据我所知,在C/C++中嵌入Python需要使用
Py\u Initialize()
Py\u Finalize()
函数

据我所知,在C/C++中嵌入Python需要使用
Py\u Initialize()
Py\u Finalize()
函数

起初,我试图导入ipfshttpclient模块,但注意到似乎任何模块都会这样做before?起初我试图导入ipfshttpclient模块,但注意到似乎任何模块都会这样做。您不应该使用
Py_Initialize()之前?啊哈!这就是我忘记的。我已经有一年左右没有使用python c api了,我完全忘记了!啊哈!这就是我忘记的。我已经有一年左右没有使用python c api了,我完全忘记了!
#include <Python.h>

int main()
{
        PyImport_ImportModule("os");
}
-I/usr/include/python3.7m -I/usr/include/python3.7m  -Wno-unused-result -Wsign-compare -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DNDEBUG -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g -DOPENSSL_LOAD_CONF -fwrapv -lpython3.7m -lpthread -ldl  -lutil -lm