gpt4 book ai didi

python - 导入 pyqtgraph 时 python 2.7 中的段错误(核心转储)

转载 作者:太空宇宙 更新时间:2023-11-03 15:03:57 25 4
gpt4 key购买 nike

所以我一直在开发一个 python 项目,在该项目中我想使用 pyqtgraph 实时绘制来自传感器的数据。

但是,当第一次尝试运行代码时,我遇到了段错误(核心转储)

我可以隔离导致崩溃的一行代码,即 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。

(我很惊讶您在崩溃之前没有收到有关此影响的警告。)

关于python - 导入 pyqtgraph 时 python 2.7 中的段错误(核心转储),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44821475/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com