4

This is related to this question but applicable to Python 3 rather than 2.x

I am trying to run the pyqtgraph example programs under Python 3.4 (Ubuntu 14.04). When I try to run the surface-plotting example I get:

tim@MERLIN:/usr/local/lib$ python3 -m pyqtgraph.examples
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/pyqtgraph-0.9.8-py3.4.egg/pyqtgraph/examples/GLSurfacePlot.py", line 12, in <module>
    import pyqtgraph.opengl as gl
  File "/usr/local/lib/python3.4/dist-packages/pyqtgraph-0.9.8-py3.4.egg/pyqtgraph/opengl/__init__.py", line 1, in <module>
    from .GLViewWidget import GLViewWidget
  File "/usr/local/lib/python3.4/dist-packages/pyqtgraph-0.9.8-py3.4.egg/pyqtgraph/opengl/GLViewWidget.py", line 1, in <module>
    from pyqtgraph.Qt import QtCore, QtGui, QtOpenGL
ImportError: cannot import name 'QtOpenGL'

Can anyone suggest what is the best way to go about installing this for Python 3 (it works great under Python 2.7)?

Community
  • 1
  • 1
TimGJ
  • 1,584
  • 2
  • 16
  • 32
  • After reading that question you linked to, why didn't you just [search ubuntu's packages](http://packages.ubuntu.com/) for the missing python3 modules? It would have been a lot quicker than posting a question here. – ekhumoro Nov 06 '14 at 22:52
  • 2
    @ekhumoro I already did. That's why I asked what's the best way of installing it. – TimGJ Nov 07 '14 at 07:02
  • 2
    Well, the accepted answer in that question you linked to suggested using `apt-get install python3-pyqt4.qtopengl`. Then if there's no ubuntu package for pyqtgraph, use `python3-pip` to install it from [PyPI](https://pypi.python.org/pypi). Of course, you could also try compiling everything from source, but it will be a lot more difficult if you're not familiar with doing that (hint: make sure you have all the relevant ubuntu dev packages installed before you start compiling stuff). – ekhumoro Nov 07 '14 at 17:53

1 Answers1

0

I just discovered that pyqtgraph, in some case, does not correctly import the python qt libs. Try to add at the beginning of your code:

import PySide

or

import PyQt5

even

import PyQt4

depending on which library you want to use by default.

Ice
  • 31
  • 4