Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.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
C++;Python解释器-Py_初始化正在崩溃 我编译了Python源代码为32位,AM试图使用 pyiRealAlsieIe())/Cuth.API来在我的C++应用程序中引入Python解释器。 Py\u Initialize()导致以下崩溃。请帮我解决这个问题_Python_C++ - Fatal编程技术网

C++;Python解释器-Py_初始化正在崩溃 我编译了Python源代码为32位,AM试图使用 pyiRealAlsieIe())/Cuth.API来在我的C++应用程序中引入Python解释器。 Py\u Initialize()导致以下崩溃。请帮我解决这个问题

C++;Python解释器-Py_初始化正在崩溃 我编译了Python源代码为32位,AM试图使用 pyiRealAlsieIe())/Cuth.API来在我的C++应用程序中引入Python解释器。 Py\u Initialize()导致以下崩溃。请帮我解决这个问题,python,c++,Python,C++,我正在编译我的代码,如下所示: g++ ./Pythoninterpreter.cpp -m32 -lpthread -ldl -lutil /usr/lib/libm.a /usr/lib/libpython2.7.a -Xlinker -export-dynamic -I/root/python_tar/Python-2.7.6/Include -I/root/python_tar/Python-2.7.6 -o pythonintepreter gdb back trace ======

我正在编译我的代码,如下所示:

g++ ./Pythoninterpreter.cpp -m32 -lpthread -ldl -lutil /usr/lib/libm.a /usr/lib/libpython2.7.a -Xlinker -export-dynamic -I/root/python_tar/Python-2.7.6/Include -I/root/python_tar/Python-2.7.6 -o pythonintepreter

gdb back trace
===============

#0  0x080e8ba7 in va_build_value (format=0x8152ec1 "", va=0xffed7564 "\240\344\027\b\244y\355\377", flags=0) at Python/modsupport.c:521
521         memcpy(lva, va, sizeof(va_list));
(gdb) bt
#0  0x080e8ba7 in va_build_value (format=0x8152ec1 "", va=0xffed7564 "\240\344\027\b\244y\355\377", flags=0) at Python/modsupport.c:521
#1  0x080e8ca6 in Py_BuildValue (format=0x8152ebe "[O]") at Python/modsupport.c:485
#2  0x080a77a7 in mro_implementation (type=0x817e4a0) at Objects/typeobject.c:1605
#3  0x080a3d68 in mro_internal (type=0x4) at Objects/typeobject.c:1636
#4  0x080a4723 in PyType_Ready (type=0x817e4a0) at Objects/typeobject.c:4057
#5  0x080a5186 in PyType_Ready (type=0x817e3c0) at Objects/typeobject.c:4005
#6  0x08088252 in _Py_ReadyTypes () at Objects/object.c:2071
#7  0x080ee3f4 in Py_InitializeEx (install_sigs=1) at Python/pythonrun.c:191
#8  0x080eee32 in Py_Initialize () at Python/pythonrun.c:382
#9  0x080598fe in PythonIntepretor::PythonIntepretor(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned short) ()
#10 0x080595fe in main ()
(gdb)
g++./Pythoninterpreter.cpp-m32-lpthread-ldl-lutil/usr/lib/libm.a/usr/lib/libpython2.7.a-Xlinker-export dynamic-I/root/python_tar/python-2.7.6/Include-I/root/python_tar/pythoninterpter-2.7.6-o pythoninterpter
gdb回溯跟踪
===============
#0 0x080e8ba7,在Python/modsupport.c:521中的va_build_值(格式=0x8152ec1“,va=0xffed7564”\240\344\027\b\244y\355\377”,标志=0)
521名成员(lva、va、sizeof(va_列表));
(gdb)英国电信
#0 0x080e8ba7,在Python/modsupport.c:521中的va_build_值(格式=0x8152ec1“,va=0xffed7564”\240\344\027\b\244y\355\377”,标志=0)
#Python/modsupport.c:485中的1 0x080e8ca6,格式为Py_BuildValue(格式=0x8152ebe“[O]”)
#在Objects/typeobject.c:1605处的mro_实现(type=0x817e4a0)中有2个0x080a77a7
#3 0x080a3d68位于对象/类型对象的mro_内部(类型=0x4)。c:1636
#在Objects/typeobject.c:4057处的PyType_Ready(type=0x817e4a0)中4 0x080a4723
#在Objects/typeobject.c:4005处的PyType_就绪(type=0x817e3c0)中的5 0x080a5186
#6 0x08088252 in_Py_ReadyTypes()位于Objects/object.c:2071
#Python/pythonrun.c:191上Py_InitializeEx(install_sigs=1)中的7 0x080ee3f4
#Python/pythonrun.c:382上Py_Initialize()中的8 0x080eee32
#9 0x080598fe-in-pythoninterptor::pythoninterptor(std::basic_string const&,无符号短)()
#主管道中的10 0x080595fe()
(gdb)

我不完全确定您想做什么,因为您没有在PythonInterpreter.cpp上提供代码

以下代码与命令行一起编译:

g++-I/usr/include/python2.7/-o foo foo.cpp-lpython2.7

#include  "Python.h"
int main()
{
  Py_Initialize();
  return 0;
}

我只是在做同样的事情。但它崩溃了。仅供参考,我已经编译了32位体系结构的python源代码。使用64位,我甚至可以成功运行代码。我编译了32位架构的python源代码。编译过程中生成的python二进制文件也会抛出相同的错误。