所以我一直在研究一个Python项目,我想在该项目中使用pyqtgraph实时绘制传感器的数据。
但是,当第一次尝试运行代码时,我得到了一个Segmentation fault (core dumped)
。
我可以隔离负责import pyqtgraph as pg
崩溃的一行代码。
运行GDB产生:
gdb python
[...]
Reading symbols from python...(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/bin/python
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyqtgraph
Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/x86_64/strlen.S:106
106 ../sysdeps/x86_64/strlen.S: No such file or directory.
(gdb) backtrace
#0 strlen () at ../sysdeps/x86_64/strlen.S:106
#1 0x00000000004ee6f6 in PyString_FromFormatV ()
#2 0x0000000000506e80 in PyErr_Format ()
#3 0x00007ffff0e69acb in ?? () from /usr/lib/python2.7/dist-packages/sip.so
#4 0x00007ffff58143a3 in initQtGui () from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
#5 0x0000000000427992 in _PyImport_LoadDynamicModule ()
#6 0x000000000055642f in ?? ()
#7 0x00000000004e2dec in ?? ()
#8 0x0000000000556cf1 in ?? ()
#9 0x0000000000569cd8 in ?? ()
#10 0x00000000004c8c8b in PyEval_CallObjectWithKeywords ()
#11 0x00000000005264a8 in PyEval_EvalFrameEx ()
#12 0x0000000000555551 in PyEval_EvalCodeEx ()
#13 0x00000000005b41e2 in PyEval_EvalCode ()
#14 0x00000000005b429a in PyImport_ExecCodeModuleEx ()
#15 0x00000000005942af in ?? ()
#16 0x000000000055642f in ?? ()
#17 0x0000000000556838 in ?? ()
#18 0x0000000000556d9b in ?? ()
#19 0x0000000000569cd8 in ?? ()
#20 0x00000000004c8c8b in PyEval_CallObjectWithKeywords ()
#21 0x00000000005264a8 in PyEval_EvalFrameEx ()
#22 0x0000000000555551 in PyEval_EvalCodeEx ()
#23 0x00000000005b41e2 in PyEval_EvalCode ()
#24 0x00000000005b429a in PyImport_ExecCodeModuleEx ()
#25 0x00000000005942af in ?? ()
#26 0x0000000000465804 in ?? ()
#27 0x000000000055642f in ?? ()
#28 0x0000000000556838 in ?? ()
#29 0x0000000000556c4b in ?? ()
#30 0x0000000000569c08 in ?? ()
#31 0x00000000004c8c8b in PyEval_CallObjectWithKeywords ()
#32 0x00000000005264a8 in PyEval_EvalFrameEx ()
#33 0x0000000000567d14 in ?? ()
#34 0x0000000000465a2d in PyRun_InteractiveOneFlags ()
#35 0x0000000000465b49 in PyRun_InteractiveLoopFlags ()
#36 0x00000000004661fe in PyRun_AnyFileExFlags ()
#37 0x0000000000466d92 in Py_Main ()
#38 0x00007ffff7814f45 in __libc_start_main (main=0x466e50 <main>, argc=1, argv=0x7fffffffd8c8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd8b8)
at libc-start.c:287
#39 0x0000000000577c2e in _start ()
(gdb)
#0 strlen () at ../sysdeps/x86_64/strlen.S:106
#1 0x00000000004ee6f6 in PyString_FromFormatV ()
#2 0x0000000000506e80 in PyErr_Format ()
#3 0x00007ffff0e69acb in ?? () from /usr/lib/python2.7/dist-packages/sip.so
#4 0x00007ffff58143a3 in initQtGui () from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
#5 0x0000000000427992 in _PyImport_LoadDynamicModule ()
#6 0x000000000055642f in ?? ()
#7 0x00000000004e2dec in ?? ()
#8 0x0000000000556cf1 in ?? ()
#9 0x0000000000569cd8 in ?? ()
#10 0x00000000004c8c8b in PyEval_CallObjectWithKeywords ()
#11 0x00000000005264a8 in PyEval_EvalFrameEx ()
#12 0x0000000000555551 in PyEval_EvalCodeEx ()
#13 0x00000000005b41e2 in PyEval_EvalCode ()
#14 0x00000000005b429a in PyImport_ExecCodeModuleEx ()
#15 0x00000000005942af in ?? ()
#16 0x000000000055642f in ?? ()
#17 0x0000000000556838 in ?? ()
#18 0x0000000000556d9b in ?? ()
#19 0x0000000000569cd8 in ?? ()
#20 0x00000000004c8c8b in PyEval_CallObjectWithKeywords ()
#21 0x00000000005264a8 in PyEval_EvalFrameEx ()
#22 0x0000000000555551 in PyEval_EvalCodeEx ()
#23 0x00000000005b41e2 in PyEval_EvalCode ()
#24 0x00000000005b429a in PyImport_ExecCodeModuleEx ()
#25 0x00000000005942af in ?? ()
#26 0x0000000000465804 in ?? ()
#27 0x000000000055642f in ?? ()
#28 0x0000000000556838 in ?? ()
#29 0x0000000000556c4b in ?? ()
#30 0x0000000000569c08 in ?? ()
#31 0x00000000004c8c8b in PyEval_CallObjectWithKeywords ()
#32 0x00000000005264a8 in PyEval_EvalFrameEx ()
#33 0x0000000000567d14 in ?? ()
#34 0x0000000000465a2d in PyRun_InteractiveOneFlags ()
#35 0x0000000000465b49 in PyRun_InteractiveLoopFlags ()
#36 0x00000000004661fe in PyRun_AnyFileExFlags ()
#37 0x0000000000466d92 in Py_Main ()
#38 0x00007ffff7814f45 in __libc_start_main (main=0x466e50 <main>, argc=1, argv=0x7fffffffd8c8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd8b8)
at libc-start.c:287
#39 0x0000000000577c2e in _start ()
(gdb)
#0 strlen () at ../sysdeps/x86_64/strlen.S:106
#1 0x00000000004ee6f6 in PyString_FromFormatV ()
#2 0x0000000000506e80 in PyErr_Format ()
#3 0x00007ffff0e69acb in ?? () from /usr/lib/python2.7/dist-packages/sip.so
#4 0x00007ffff58143a3 in initQtGui () from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
#5 0x0000000000427992 in _PyImport_LoadDynamicModule ()
#6 0x000000000055642f in ?? ()
#7 0x00000000004e2dec in ?? ()
#8 0x0000000000556cf1 in ?? ()
#9 0x0000000000569cd8 in ?? ()
#10 0x00000000004c8c8b in PyEval_CallObjectWithKeywords ()
#11 0x00000000005264a8 in PyEval_EvalFrameEx ()
#12 0x0000000000555551 in PyEval_EvalCodeEx ()
#13 0x00000000005b41e2 in PyEval_EvalCode ()
#14 0x00000000005b429a in PyImport_ExecCodeModuleEx ()
#15 0x00000000005942af in ?? ()
#16 0x000000000055642f in ?? ()
#17 0x0000000000556838
在Python3中运行相同的运行效果完全很好,但是使用Python3对我来说不是一个选择,因为这与我项目框架的很大一部分相抵触。
我还尝试通过PIP重新安装pyqtgraph。
$ pip show pyqtgraph
Name: pyqtgraph
Version: 0.10.0
Summary: Scientific Graphics and GUI Library for Python
Home-page: http://www.pyqtgraph.org
Author: Luke Campagnola
Author-email: luke.campagnola@gmail.com
License: MIT
Location: /usr/local/lib/python3.4/dist-packages
Requires: numpy
我已经搜索和尝试了几个小时,但没有找到任何解决方案,所以我感谢任何帮助。
欢呼
绝望的程序员。
我不相信python 2.x和3.x是链接兼容的。
您将3.x模块加载到2.x Python中,这根本不期望工作。
您需要构建(或在某处找到(2.x版本的Pyqtgraph。
(我很惊讶您在崩溃之前不会警告这种影响。(