From 4b0505b2ca9b374921e98702553c30820778353a Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Wed, 25 Jul 2018 14:15:27 +0900 Subject: [PATCH 1/2] pyqtgraph < 0.10 fail to run `from pyqtgraph import __version__ `, use pkg_resources ``` $ rqt_plot /joint_state/position[0] Traceback (most recent call last): File "/opt/ros/kinetic/bin/rqt_plot", line 6, in from rqt_plot.plot import Plot File "/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_plot/plot.py", line 43, in from .data_plot import DataPlot File "/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_plot/data_plot/__init__.py", line 44, in from .pyqtgraph_data_plot import PyQtGraphDataPlot File "/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_plot/data_plot/pyqtgraph_data_plot.py", line 46, in from pyqtgraph import __version__ as pyqtgraph_version File "/usr/lib/python2.7/dist-packages/pyqtgraph/__init__.py", line 13, in from .Qt import QtGui File "/usr/lib/python2.7/dist-packages/pyqtgraph/Qt.py", line 104, in from PyQt4 import QtGui, QtCore, uic RuntimeError: the PyQt4.QtCore and PyQt5.QtCore modules both wrap the QObject class ``` --- src/rqt_plot/data_plot/pyqtgraph_data_plot.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rqt_plot/data_plot/pyqtgraph_data_plot.py b/src/rqt_plot/data_plot/pyqtgraph_data_plot.py index 3f0f96a..35b1b29 100644 --- a/src/rqt_plot/data_plot/pyqtgraph_data_plot.py +++ b/src/rqt_plot/data_plot/pyqtgraph_data_plot.py @@ -43,7 +43,12 @@ def parse_version(s): return [int(x) for x in re.sub(r'(\.0+)*$', '', s).split('.')] - from pyqtgraph import __version__ as pyqtgraph_version + try: + from pyqtgraph import __version__ as pyqtgraph_version + except: + import pkg_resources + pyqtgraph_version = pkg_resources.get_distribution("pyqtgraph").version + if parse_version(pyqtgraph_version) < parse_version('0.10.0'): raise ImportError('A newer PyQtGraph version is required (at least 0.10 for Qt 5)') From 8e22af0039b49a5cd12c662d5bd780bf4a80057a Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Tue, 31 Jul 2018 17:57:44 +0900 Subject: [PATCH 2/2] cath RuntimeError and add a comment when it is expected to be raised. --- src/rqt_plot/data_plot/pyqtgraph_data_plot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rqt_plot/data_plot/pyqtgraph_data_plot.py b/src/rqt_plot/data_plot/pyqtgraph_data_plot.py index 35b1b29..719e118 100644 --- a/src/rqt_plot/data_plot/pyqtgraph_data_plot.py +++ b/src/rqt_plot/data_plot/pyqtgraph_data_plot.py @@ -45,7 +45,9 @@ def parse_version(s): try: from pyqtgraph import __version__ as pyqtgraph_version - except: + except RuntimeError: + # pyqtgraph < 1.0 using Qt4 failing on 16.04 because kinetic uses Qt5. + # This raises RuntimeError('the PyQt4.QtCore and PyQt5.QtCore modules both wrap the QObject class') import pkg_resources pyqtgraph_version = pkg_resources.get_distribution("pyqtgraph").version