PyQt5 Stubs
raw JSON → 5.15.6.0 verified Fri May 01 auth: no python
PEP 561 compliant stub files (type hints) for the PyQt5 framework. Provides type information for static type checkers like mypy and Pyright. Current version 5.15.6.0, compatible with PyQt5 5.15.x. Released as needed for PyQt5 updates.
pip install PyQt5-stubs Common errors
error No module named 'PyQt5' ↓
cause PyQt5 itself not installed.
fix
pip install PyQt5
error Cannot find reference 'QWidget' in '__init__.pyi' ↓
cause IDE or type checker not finding stubs due to missing PyQt5-stubs install.
fix
pip install PyQt5-stubs
error PyQt5-stubs 5.15.6.0 requires Python >=3.5, but Python 3.4 is installed ↓
cause Unsupported Python version.
fix
Upgrade Python to 3.5 or later.
Warnings
deprecated PyQt5-stubs is no longer actively maintained; consider migrating to PyQt6 with PyQt6-stubs. ↓
fix Switch to PyQt6 and PyQt6-stubs for active support.
gotcha Stubs may not cover newer PyQt5 submodules (e.g., QtWebEngine, Qt3D) as thoroughly. ↓
fix Check stub coverage; report missing stubs upstream.
breaking In version 5.15.2.0, strict mypy mode was enabled; existing code with untyped signals/slots may cause new errors. ↓
fix Add type annotations to signals/slots or use `# type: ignore` locally.
Imports
- QWidget wrong
from PyQt5.QtGui import QWidgetcorrectfrom PyQt5.QtWidgets import QWidget - QPushButton
from PyQt5.QtWidgets import QPushButton
Quickstart
import sys
from PyQt5.QtWidgets import QApplication, QPushButton
app = QApplication(sys.argv)
button = QPushButton('Click me')
button.show()
sys.exit(app.exec_())