Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyqtgraph < 0.10 fail to run from pyqtgraph import __version__ , us… #13

Merged
merged 2 commits into from
Jul 31, 2018

Conversation

k-okada
Copy link
Contributor

@k-okada k-okada commented Jul 25, 2018

…e pkg_resources

@dirk-thomas 's fix at ros-visualization/rqt_common_plugins#415 failing on default kinetic enviroment whcih uses 0.9.10 of python-pyqtgraph https://packages.ubuntu.com/xenial/python-pyqtgraph

$ rqt_plot /joint_state/position[0]
Traceback (most recent call last):
  File "/opt/ros/kinetic/bin/rqt_plot", line 6, in <module>
    from rqt_plot.plot import Plot
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_plot/plot.py", line 43, in <module>
    from .data_plot import DataPlot
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_plot/data_plot/__init__.py", line 44, in <module>
    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 <module>
    from pyqtgraph import __version__ as pyqtgraph_version
  File "/usr/lib/python2.7/dist-packages/pyqtgraph/__init__.py", line 13, in <module>
    from .Qt import QtGui
  File "/usr/lib/python2.7/dist-packages/pyqtgraph/Qt.py", line 104, in <module>
    from PyQt4 import QtGui, QtCore, uic
RuntimeError: the PyQt4.QtCore and PyQt5.QtCore modules both wrap the QObject class

…e pkg_resources

```
$ rqt_plot /joint_state/position[0]
Traceback (most recent call last):
  File "/opt/ros/kinetic/bin/rqt_plot", line 6, in <module>
    from rqt_plot.plot import Plot
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_plot/plot.py", line 43, in <module>
    from .data_plot import DataPlot
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_plot/data_plot/__init__.py", line 44, in <module>
    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 <module>
    from pyqtgraph import __version__ as pyqtgraph_version
  File "/usr/lib/python2.7/dist-packages/pyqtgraph/__init__.py", line 13, in <module>
    from .Qt import QtGui
  File "/usr/lib/python2.7/dist-packages/pyqtgraph/Qt.py", line 104, in <module>
    from PyQt4 import QtGui, QtCore, uic
RuntimeError: the PyQt4.QtCore and PyQt5.QtCore modules both wrap the QObject class
```
@dirk-thomas
Copy link
Contributor

The python-pyqtgraph package on Xenial is using Qt 4 and will therefore not be compatible with RQt in Kinetic because it targets Qt 5 (hence the version check).

I am not sure what this patch should achieve - especially since the version comparion is left untouched which raises a RuntimeError for that version of pyqtgraph?

@k-okada
Copy link
Contributor Author

k-okada commented Jul 25, 2018

from pyqtgraph import __version__ as pyqtgraph_version itself failed with pyqtgraph < 0.10 (?) because , when we evaluate this line, it also try to read all

  File "/usr/lib/python2.7/dist-packages/pyqtgraph/__init__.py", line 13, in <module>

file and that includes

    from .Qt import QtGui

which raises error

RuntimeError: the PyQt4.QtCore and PyQt5.QtCore modules both wrap the QObject class

as seen in error message.

This PR catch this exception and try with other method, using pkg_resource to get the version number string. May be

- from pyqtgraph import __version__ as pyqtgraph_version
+ import pkg_resources
+ pyqtgraph_version = pkg_resources.get_distribution("pyqtgraph").version

would be ok.

from pyqtgraph import __version__ as pyqtgraph_version
try:
from pyqtgraph import __version__ as pyqtgraph_version
except:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please catch a specific exception type here as well as add a comment when it is expected to be raised.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dirk-thomas sorry for late, updated to catch only "RuntimeError"

@dirk-thomas
Copy link
Contributor

Thank you for the patch and the update.

@dirk-thomas dirk-thomas merged commit 3bb45cf into ros-visualization:master Jul 31, 2018
@k-okada k-okada deleted the patch-1 branch August 1, 2018 06:55
mlautman pushed a commit that referenced this pull request Dec 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants