PyQt5 SIP Module Support
The `pyqt5-sip` package provides the SIP module, which is essential support for PyQt5. SIP is a powerful tool for creating Python bindings for C and C++ libraries, originally developed for the Qt toolkit. The current version is 12.18.0, with ongoing maintenance releases to ensure compatibility and provide bug fixes.
Warnings
- breaking When upgrading PyQt5 to version 5.14.0 or later, applications might encounter `ModuleNotFoundError: No module named 'PyQt5.sip'`. This is due to changes in how the `sip` module is packaged and located within the library.
- gotcha Building `pyqt5-sip` or PyQt5 from source on Windows requires a compatible C++ compiler, specifically Microsoft Visual C++ 14.0 or greater (often obtained via 'Microsoft C++ Build Tools').
- gotcha Newer versions of SIP (and consequently `pyqt5-sip`) have increased their minimum Python version requirement. `pyqt5-sip` 12.18.0 requires Python >= 3.10.
- deprecated The `sipconfig` module, previously used for configuring SIP bindings, is considered outdated. For developers creating C++ bindings, the modern approach involves `sip-build` and `PyQt-builder`.
Install
-
pip install PyQt5-sip
Imports
- sip
import sip
Quickstart
import sys
from PyQt5.QtWidgets import QApplication, QLabel, QWidget
from PyQt5.QtCore import Qt
# This simple PyQt5 app implicitly relies on pyqt5-sip
# for its underlying C++/Python bindings.
def main():
app = QApplication(sys.argv)
window = QWidget()
window.setWindowTitle("PyQt5 SIP Check")
window.setGeometry(100, 100, 300, 200)
label = QLabel("Hello, PyQt5 with SIP!", window)
label.setAlignment(Qt.AlignCenter)
label.setGeometry(0, 0, 300, 200)
window.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()