PyQt6-Qt Core Components
The `pyqt6-qt` package is a crucial runtime dependency for `PyQt6`, providing the necessary compiled Qt binaries and libraries. It is not intended for direct import or use by application developers but is automatically installed and utilized by the `PyQt6` package to enable GUI functionality. The current version is 6.0.1, reflecting its close tie to the PyQt6 release cycle.
Common errors
-
ModuleNotFoundError: No module named 'PyQt6'
cause The user installed `pyqt6-qt` but forgot to install the `PyQt6` package itself. `pyqt6-qt` only provides the Qt binaries, not the Python bindings.fixInstall the `PyQt6` package: `pip install PyQt6`. This will automatically install `pyqt6-qt` as a dependency if needed. -
qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""
cause The Qt runtime cannot locate its platform plugins, which are essential for GUI rendering. This often happens in custom environments, virtual environments, or deployed applications where the paths are not correctly resolved.fixEnsure the `platforms` folder within your PyQt6 installation's Qt6 directory is accessible. For deployment, ensure this folder is bundled. In development, try setting the `QT_QPA_PLATFORM_PLUGIN_PATH` environment variable to point to the `PyQt6/Qt6/plugins` directory within your site-packages. -
AttributeError: module 'PyQt6' has no attribute 'QtWidgets'
cause This usually indicates that the `PyQt6` package is either not fully installed, corrupted, or there's a version mismatch between `PyQt6` and its `pyqt6-qt` backend.fixTry reinstalling `PyQt6` and `pyqt6-qt` to ensure consistency: `pip uninstall PyQt6 pyqt6-qt -y && pip install PyQt6`. Check your Python environment for conflicts or partial installations.
Warnings
- gotcha Confusion between 'pyqt6-qt' and 'PyQt6'. Users often mistake `pyqt6-qt` for the main Python-facing library and attempt to import directly from it.
- gotcha Deployment challenges with bundled applications. When creating standalone executables (e.g., with PyInstaller), the Qt shared libraries provided by `pyqt6-qt` must be correctly bundled for the application to run on other machines.
- gotcha Environment variable QT_QPA_PLATFORM_PLUGIN_PATH not set or pointing to incorrect location, leading to 'Could not find the Qt platform plugin' errors.
Install
-
pip install pyqt6-qt -
pip install PyQt6
Imports
- QApplication (enabled by pyqt6-qt)
from PyQt6.QtWidgets import QApplication
Quickstart
import sys
from PyQt6.QtWidgets import QApplication, QLabel, QWidget
# Note: pyqt6-qt provides the underlying Qt libraries,
# enabling the functionality imported from PyQt6.
def main():
app = QApplication(sys.argv)
window = QWidget()
window.setWindowTitle('PyQt6-Qt Enabled App')
window.setGeometry(100, 100, 280, 80)
hello_label = QLabel('Hello, PyQt6!', parent=window)
hello_label.move(60, 15)
window.show()
sys.exit(app.exec())
if __name__ == '__main__':
main()