[Python] How to install the PyQt5?

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

  1. Stack

    Stack Membro Participativo

    I have been searching to resolve this problem for two days. I tried a lot of ways, searched the answer on google, but didn't find a single solution to the problem. I want to know why PyQt5 is not working even if it is installed.

    Although the pip show option is working, and the pip install option is already satisfied but it is still causing the issue and the code is not executing.

    Code

    from PyQt5 import QtWidgets
    from PyQt5.QtWidgets import QApplication, QMainWindow
    import sys

    def window():
    app = QApplication(sys.argv)
    win = QMainWindow()
    win.setGeometry(1000, 200, 300, 300)
    win.setWindowTitle("ibilalkayy")

    win.show()
    sys.exit(app.exec_())
    window()


    pip show PyQt5 result

    Name: PyQt5
    Version: 5.15.2
    Summary: Python bindings for the Qt cross platform application toolkit
    Home-page: https://www.riverbankcomputing.com/software/pyqt/
    Author: Riverbank Computing Limited
    Author-email: info@riverbankcomputing.com
    License: GPL v3
    Location: /usr/lib/python3/dist-packages
    Requires: PyQt5-sip
    Required-by: PyQtWebEngine


    pip install PyQt5==5.15.2

    Requirement already satisfied: PyQt5==5.15.2 in /usr/lib/python3/dist-packages (5.15.2)
    Requirement already satisfied: PyQt5-sip<13,>=12.8 in /usr/lib/python3/dist-packages (from PyQt5==5.15.2) (12.8.1)


    Code execution and error

    python3 /Path/to/tutorial.py
    Traceback (most recent call last):
    File "/Path/to/tutorial.py", line 1, in <module>
    from PyQt5 import QtWidgets
    ModuleNotFoundError: No module named 'PyQt5'

    Continue reading...

Compartilhe esta Página