1. Install pyqt4
We recommend that you use apt-get to install pyqt4.
sudo apt-get install libxext6 libxext-dev libqt4-dev libqt4-gui libqt4-sql qt4-dev-tools qt4-doc qt4-designer qt4-qtconfig "python-qt4-*" python-qt4
Very simple. It mainly records pyqt5 in the python3 environment.
2. Install pyqt5
2.1.python sip install
First download the SIP
tar -xvf sip*.tar.gz python configure.py make sudo make install
2.2 install qt5
Here is the source download, http://www.riverbankcomputing.co.uk/software/pyqt/download5
There are also run file downloads, http://qt-project.org/downloads
Source or./configure & make & sudo make install. If it is run, add the X permission first.
Sudo chmod + x **. Run
After installation, add the path to the environment variable ~ /. Bash_profile, mine is
export PATH=$PATH:/opt/Qt5.3.1/5.3/gcc_64/bin
sudo ln -s /opt/Qt5.3.1/5.3/gcc_64/bin/qmake /usr/local/bin
2.3 pyqt5 install
To install pyqt5, you need the above sip and qmake. Therefore, you need to install qt5 first.
Replace the following qmake with your directory and site-packages/, that is, the package location, and then compile
$python configure.py
Install
sudo make && sudo make install
A simple example is as follows:
import sys from PyQt5 import QtCore, QtGui, QtWidgets if __name__ == ‘__main__‘: app = QtWidgets.QApplication(sys.argv) w = QtWidgets.QWidget() w.resize(250, 150) w.move(300, 300) w.setWindowTitle(‘Simple‘) w.show() sys.exit(app.exec_())
If any compilation error occurs, try
sudo ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"
Add the command
Ubuntu 14 configure and install pyqt4 and pyqt5