1

I'm having problems with imports, qtopengl, pyqtgraph, and designer version compatibility. Depending upon package installation, either designer will not load custom plugins, with a libQt5Core.so ImportError, or GLViewWidgets fail with QtOpenGl ImportError.

My question(s):

  • Is there a compatibility problem?
  • A version problem?
  • Has anyone resolved either of these issues separately before? I'm not sure if, or how they may be connected.
  • Is there a way to get both situations working at the same time?

Installation: (python3.6, ubuntu 18.04)

pip3 install --user pyqt5  # -> PyQt5-5.12.2
pip3 install --user pyqtgraph  # -> 0.10.0
apt-get install python3-pyqt5

When the pip3 pyqt5 package is NOT installed, designer opens and loads the custom widget plugin successfully. But, running a basic pyqtgraph GLViewWidget results in:

from ..Qt import QtCore, QtGui, QtOpenGL, USE_PYQT5
ImportError: cannot import name 'QtOpenGL'

When the pip3 pyqt5 package IS installed, running the basic pyqtgraph GLViewWidget is successful. But designer fails to load the custom widget plugin with:

from PyQt5 import QtWidgets, QtCore
ImportError: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /home/USER/.local/lib/python3.6/site-packages/PyQt5/QtWidgets.so)

Note: The custom widget plugin is entirely unrelated to GLViewWidget, and the GLViewWidget is entirely unrelated to designer. The GLViewWidget comes from pyqtgraph, but error is just on import (so far), so pyqtgraph probably is not a source of the problem. Will experiment with this further.


code to try the GLViewWidget

from pyqtgraph import opengl as gl, mkQApp  # fails here
app = mkQApp()
view = gl.GLViewWidget()
view.show()
app.exec()

designer plugin minimal example (QVLabel_plugin.py)

from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtDesigner import QPyDesignerCustomWidgetPlugin

class QVLabel(QtWidgets.QLabel):
    pass

class QVLabelPlugin(QPyDesignerCustomWidgetPlugin):
        def __init__(self, parent=None):
            QPyDesignerCustomWidgetPlugin.__init__(self)
            self.initialized = False
        def initialize(self, formEditor):
            if self.initialized:
                return
            self.initialized = True
        def isInitialized(self):
            return self.initialized
        def createWidget(self, parent):
            return QVLabel(parent=parent)
        def name(self):
            return "QVLabel"
        def group(self):
            return "Custom Widgets"
        def icon(self):
            return None  # will raise TypeError in designer, but everything should work fine
        def toolTip(self):
            return ''
        def whatsThis(self):
            return ''
        def isContainer(self):
            return True
        def includeFile(self):
            return "QVLabel_plugin"

running designer in the directory of the QVLabel_plugin.py

PYQTDESIGNERPATH=. designer

How GL fails:

from ..Qt import QtCore, QtGui, QtOpenGL, USE_PYQT5
ImportError: cannot import name 'QtOpenGL'

How designer fails:

from PyQt5 import QtWidgets, QtCore
ImportError: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /home/USER/.local/lib/python3.6/site-packages/PyQt5/QtWidgets.so)
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Tim
  • 168
  • 9
  • Just install a version of PyQt5: or pip3 install --user pyqt5 or apt-get install python3-pyqt5 as you realize the version of PyQt5 that provides pip is different to apt-get so you will see conflict of versions, IMHO uninstall both python and uses only apt-get – eyllanesc Jun 13 '19 at 06:01
  • If you use apt-get then execute apt-get install python-pyqt5.qtopengl to install QtOpenGL – eyllanesc Jun 13 '19 at 06:01
  • I tried just using pip installs, but the designer doesn't even attempt to load the plugins (I didn't know the pip method even included designer before now). Using the apt method, my IDE's don't even recognize PyQt5 as being installed (no code completion or lookup). – Tim Jun 13 '19 at 06:10
  • Do not use pip, ubuntu offers those packages. When you install pip it will use different binaries than the OS provides. As you point out, uninstall both pyqt5 and install only with apt-get – eyllanesc Jun 13 '19 at 06:12
  • What is your IDE? Are you sure that your IDE is using the version of python that uses apt-get ?, if it is pycharm then you must configure it to use the python of the OS since it is normally configured to work with a virtualenv – eyllanesc Jun 13 '19 at 06:14
  • I've been using PyCharm, everything is configured to run from the main python env (no virtuals even set up), but I get the 'Requirement not satisfied' warning. I'm trying apt method now, with the python3-pyqt5.qtopengl and the GLViewWidget gives me the same error as before. – Tim Jun 13 '19 at 06:42

2 Answers2

1

This worked for the "ImportError: cannot import name 'QtOpenGL'"

sudo apt-get install python3-pyqt4.qtopengl

see: Just installed QtOpenGL but cannot import it (from Python)

user881763
  • 19
  • 6
0

python3-pyqt4.qtopengl is depreciated and the new version is python3-pyqt5.qtopengl.

new command:

sudo apt install python3-pyqt5.qtopengl
desertnaut
  • 57,590
  • 26
  • 140
  • 166