On Raspberry Pi OS or another Debian-based Raspberry Pi system, install PyQt5 from the system package repository rather than building it manually. This keeps the Qt libraries, development headers, and Python bindings matched to the packages provided by the distribution.
sudo apt-get update
sudo apt-get install qt5-default pyqt5-dev pyqt5-dev-tools
If you are writing Python 3 applications, also check whether the runtime binding package is already installed. On many Raspberry Pi OS releases it is provided as python3-pyqt5:
sudo apt-get install python3-pyqt5
You can verify the installation with a short import test:
python3 -c "from PyQt5 import QtCore; print(QtCore.QT_VERSION_STR)"
For older projects that still require PyQt4, install the Qt4 packages instead:
sudo apt-get install qt4-default qt4-designer qt4-doc qt4-dev-tools python-qt4
PyQt4 is legacy software, so availability depends on the Raspberry Pi OS or Debian release you are using. If apt-get cannot find those packages, check your OS release and package repository first before trying to build PyQt4 from source.
