因此,我一直在从事一个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: [email protected]
License: MIT
Location: /usr/local/lib/python3.4/dist-packages
Requires: numpy
我已经搜索并尝试了几个小时,但尚未找到任何解决方案,因此,我将不胜感激。
干杯
绝望的程序员。
最佳答案
我不认为Python 2.x和3.x是链接兼容的。
您正在将3.x模块加载到2.x Python中,这简直是行不通的。
您需要构建(或在某处找到)pyqtgraph的2.x版本。
(我很惊讶您在崩溃之前没有收到有关此影响的警告。)
关于python - 导入pyqtgraph时在python 2.7中出现段错误(核心已转储),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44821475/