1. The prerequisite is to install python
On the embedded ARM64 development platform, pip cannot install pyqt5. Those who have installed python can skip this step. I installed python3.9 here.
2. Install PyQt5 and SIP
PyQt5 version needs to correspond to SIP
sip 4.19.25 download
pyqt5 5.15.2 download
1. Source code compilation needs to rely on the qmake tool chain
sudo apt-get install qt5-default
2. Install the software packages required for compilation
sudo apt-get install cmake gcc g++
pip3 install --upgrade pip
pip3 install wheel setuptools
3. Compile SIP package
tar zxvf sip-4.19.25.tar.gz
cd ./sip-4.19.25
python configure.py --sip-module PyQt5.sip
sudo make
sudo make install
4. Compile PyQt5
tar zxvf PyQt5-5.15.2.tar.gz
cd ./PyQt5-5.15.2
python configure.py
May occur during compilation
error: Qt::ItemDataRole is not a class or namespace
Solution: This is because the compilation method used by C++ does not read. You need to add the -std=c++ 11 option after CXXFLAGS in MakeFile in all directories before
continuing.
sudo make -j4
sudo make install
3. Test
#测试PyQt5的功能
import sys
from PyQt5 import QtWidgets, QtCore
app = QtWidgets.QApplication(sys.argv)
widget = QtWidgets.QWidget()
widget.resize(360, 360)
widget.setWindowTitle("Hello, World")
widget.show()
sys.exit(app.exec_())