PyQt5 failing import of QtGui

Assuming everything was installed correctly, you need to adjust your imports slightly to port from PyQt4 to PyQt5.

The main GUI elements are in the QtWidgets module, whilst the more basic GUI elements are in QtGui. See the Qt modules page for more details.

The example code needs to be changed to something like:

from PyQt5 import QtCore, QtGui, QtWidgets

class MainWindow(QtWidgets.QMainWindow, UI.MainUI.Ui_MainWindow):

For more details on porting from PyQt4 to PyQt5, see: Differences Between PyQt4 and PyQt5.

Leave a Comment