Skip to content

Instantly share code, notes, and snippets.

@calumroy
Last active April 8, 2018 13:04
Show Gist options
  • Save calumroy/039315ba06be733fdb696374da3fa9b1 to your computer and use it in GitHub Desktop.
Save calumroy/039315ba06be733fdb696374da3fa9b1 to your computer and use it in GitHub Desktop.
PyQt5.7 installation with virtualenvs

You can try (as explained in the comments) to compile PyQt5.7 yourself, using a different version of Python (3.4.3 and 3.4.4 worked for me, everything above 3.5 did not). Note that I also compiled Qt5.7 myself, but you can use the one provided by the installer. Here is a short, hopefully exhaustive, set of commands to setup a virtual environment:

Install dependencies using apt-get:

sudo apt-get install -y build-essential libgl1-mesa-dev libx11-dev libxext-dev libxfixes-dev libxi-dev libxrender-dev libxcb1-dev libx11-xcb-dev libxcb-glx0-dev libfontconfig1-dev libfreetype6-dev libglu1-mesa-dev libssl-dev libcups2-dev python3-pip git

Install Python 3.4.4:

cd ~/Downloads
wget https://www.python.org/ftp/python/3.4.4/Python-3.4.4.tar.xz
tar xf Python-3.4.4.tar.xz
cd Python-3.4.4
./configure
sudo make install

Create the virtual environment:

sudo pip3 install virtualenv
virtualenv -p /usr/local/bin/python3.4 ~/python34
source ~/python34/bin/activate

Install Qt:

cd ~/Downloads
git clone git://code.qt.io/qt/qt5.git
cd ~/Downloads/qt5
git checkout 5.7
./init-repository
./configure -prefix ~/Qt/5.7/gcc_64 -opensource -nomake examples -nomake tests -release -confirm-license
make -j 5
make install

Install SIP:

cd ~/Downloads
wget http://downloads.sourceforge.net/project/pyqt/sip/sip-4.18.1/sip-4.18.1.tar.gz
tar xf sip-4.18.1.tar.gz
cd sip-4.18.1
python configure.py
make
sudo make install

Install PyQt:

cd ~/Downloads
wget http://downloads.sourceforge.net/project/pyqt/PyQt5/PyQt-5.7/PyQt5_gpl-5.7.tar.gz
tar xf PyQt5_gpl-5.7.tar.gz
cd PyQt5_gpl-5.7
python configure.py --qmake ~/Qt/5.7/gcc_64/bin/qmake --disable QtPositioning --no-qsci-api --no-designer-plugin --no-qml-plugin --confirm-license
make -j 5
sudo make install

Add PyQt5 to your python path

edit ~.bashrc and add the following first check PyQt5 is installed in usr/lib/python3.4/dist-packages It could be placed in site-packages instead

export PYTHONPATH=$PYTHONPATH:/usr/lib/python3.4/dist-packages

Set the python version to use in a virtualenv wrapper

Make sure python3 is installed already and virtualenv wrapper is installed, then:

mkvirtualenv --python=/usr/bin/python3 nameofvirtualenv
workon nameofvirtualenv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment