No module named PyQt5.QtWidgets in Maya 2018

Question:

Executing this code in Maya 2018 I’ve got an error:

# Error: ImportError: file <maya console> line 3: No module named PyQt5.QtWidgets #

Isn’t PyQt5 a part of Maya 2018?

import maya.cmds as cmds
import sys 
from PyQt5.QtWidgets import (QWidget, QToolTip, QPushButton) 
from PyQt5.QtGui import QFont     

class Example(QWidget):
    def __init__(self):
        super(Example,self).__init__()
        self.initUI()

    def initUI(self):
        QToolTip.setFont(QFont('SansSerif', 10))
        self.setToolTip('This is a <b>QWidget</b> widget')
        btn = QPushButton('Button', self)
        btn.setToolTip('This is a <b>QPushButton</b> widget')
        btn.resize(btn.sizeHint())
        btn.move(50, 50) 
        self.setGeometry(300, 300, 300, 200)
        self.setWindowTitle('Tooltips')
        self.show()

ex = Example() 
Asked By: mckade.charly

||

Answers:

Qt is part of Maya, but if you want to use PyQt5 you need to build it. Be careful, you need to build it against maya’s modified version of Qt.

pyQt5 instruction for maya

Answered By: rfkortekaas

were you able to fix this issue as I ,tried to follow those steps , but it did not get fix . Need help.

can anyone post a link for a video it will be of great help .
Btw I am using maya 2020

thanks , in advance

Answered By: mayaCodes
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.