[Python] PyQt5 isn't uderstood from VS Code

Discussão em 'Python' iniciado por Stack, Maio 12, 2025.

  1. Stack

    Stack Membro Participativo

    I have an issue with PyQt5 and VS Code. I have installed PyQt5 on my computer but when I write from VS Code it doesn't work. VS Code underlines my imports with a yellow line and when I run the code it says

    from PyQt5 import QtWidgets
    ImportError: No module named PyQt5.


    However, when I run the same program from my terminal, it runs fine. My code is

    import sys

    from PyQt5.uic import loadUi
    from PyQt5 import QtWidgets
    from PyQt5.QtWidgets import QDialog, QApplication, QWidget,QStackedWidget




    class Window(QDialog):
    def __init__(self):
    super(Window, self).__init__()
    loadUi("window.ui",self)

    app= QApplication(sys.argv)
    window = Window()
    widget = QStackedWidget()

    widget.addWidget(window)
    widget.setFixedHeight(800)
    widget.setFixedWidth(1200)
    widget.show()
    try:
    sys.exit(app.exec())
    except:
    print("Exiting")

    Continue reading...

Compartilhe esta Página