Tim
Tim

Reputation: 168

PyQt5 installation results in designer, qtopengl, possibly pyqtgraph errors

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):


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)

Upvotes: 1

Views: 1743

Answers (2)

kosidon
kosidon

Reputation: 1

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

new command:

sudo apt install python3-pyqt5.qtopengl

Upvotes: 0

user881763
user881763

Reputation: 19

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)

Upvotes: 1

Related Questions