Am I correctly importing the pyqt module library? Execution returns error "module called qdialog is not found"

95 Views Asked by At

I tried to run this code and it says a module called qdialog is not found.

import sys  # We need sys so that we can pass argv to QApplication
import commentAnalyzer
import design
from PyQt5 import QtGui
from PyQt5.QtCore import *
from PyQt5.QtGui import QDialog, QPushButton, QLabel
from PyQt5.QtCore import SIGNAL

I tried to run this and I got:

ImportError: cannot import name 'QDialog' from 'PyQt5.QtGui'
2

There are 2 best solutions below

0
Dickens A S On

You can adjust the import like below

from PyQt5.QtWidgets import QDialog

QDialog is inside QtWidgets

0
mahkitah On

This are the imports without redundancy and non-existent modules:

import sys
import commentAnalyzer
import design

from PyQt5.QtWidgets import QDialog, QPushButton, QLabel
from PyQt5.QtCore import pyqtSignal