Before installing new versions of packages, it is recommended to update your system. Open a terminal and run the following command:
sudo apt update && sudo apt upgrade
To install PyQt6 and its dependent libraries, use pip (When running pip, do so as a normal user and not as superuser to avoid permission conflicts). Run the following command:
pip install PyQt6 PyQt6-Qt6 PyQt6-sip
If you don't have pip installed, you can install it with:
sudo apt install python3-pip
To confirm that PyQt6 has been installed correctly, run the following command:
python3 -c "import PyQt6; print(PyQt6.__version__)"
You should see the version of PyQt6 installed.
To remove PyQt5 from the system, first uninstall the main package:
sudo apt remove python3-pyqt5
Then, remove PyQt5-related packages and their residual files:
sudo apt remove --purge python3-pyqt5.qtquick python3-pyqt5.qtsvg python3-pyqt5.qtwebengine python3-pyqt5.qtmultimedia
Finally, clean up any dependencies that are no longer needed and remove any residual configuration files:
sudo apt autoremove
sudo apt clean