为什么PyImport_ImportModule python 3.7.2 中出现段错误?
Why does PyImport_ImportModule segfault in python 3.7.2?
在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
#include <Python.h>
int main()
{
PyImport_ImportModule("os");
}
我在这里做错了什么,还是这是一个错误?
我正在使用这些编译标志(只是 python3-config --cflags 和 --libs 的输出(:
-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
据我了解,在C/C++中嵌入Python需要您使用Py_Initialize()
和Py_Finalize()
函数。
相关文章:
- 编写代码时C++出现错误:错误 1 错误 C2601:'circle':本地函数定义是非法的
- 如何摆脱C ++中的分段错误错误?
- Clang 8 带有静态 constexpr 和数组的链接器错误 - 错误是什么以及如何解决它?
- 为什么每当我尝试运行此链接列表删除功能时都会收到分段错误错误?
- 如何解决分段错误错误C++
- 作为参数模板的模板类:MSVC 错误 - 错误 C2977:模板参数过多 (C++98)
- 安卓工作室 |CPP 文件错误错误: 位图库中对"AndroidBitmap_unlockPixels"的未定义引用
- 卷曲给出分段错误错误
- 无法访问 Arduino 结构字段。错误"退出状态 1。xxxx 不命名类型"
- 错误错误 C2872:"布尔值":kinect.h 的不明确符号
- C++打印模板容器错误(错误:"运算符<<"的不明确重载)理解?
- 结构的分割错误错误
- 为什么此代码返回分段错误错误?
- 错误错误:无法编译内置功能
- 分段错误错误C++
- C++ 1Z 错误:错误:演绎指南中声明中的显式限定
- 使用对数据类型的向量的哈希表中的分段错误错误
- 为什么此代码会导致分段错误错误
- JNA结构字段值错误
- C++段故障错误