Skip to content

Instantly share code, notes, and snippets.

@rllola
Last active May 11, 2020 12:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rllola/da97b890a79d206f00a909bc2a56598d to your computer and use it in GitHub Desktop.
Save rllola/da97b890a79d206f00a909bc2a56598d to your computer and use it in GitHub Desktop.
How to install PyQt5 (5.11.2) with from source for python2.7
#!/bin/bash
NP="$(nproc)"
PYQTSIP_VERSION=4.19.14
QT5_VERSION=5.12
QT5_PATH=/opt/qt512
# This was painful for me so I though I would share. ONLY FOR LINUX!
echo "=========== Install QT 5.12.0 ==========="
# https://launchpad.net/~beineri/+archive/ubuntu/opt-qt-5.12.0-xenial
sudo add-apt-repository --yes ppa:beineri/opt-qt-5.12.0-xenial
sudo apt-get update
# Install Qt5, QtWebEngine and QtSvg (for creating a browser)
sudo apt-get install -y msgpack-python python-gevent python-dev build-essential libgl1-mesa-dev qt512-meta-minimal qt512webengine qt512svg
echo "Done !"
echo "=========== Install SIP ==========="
# Remove -nv to have info on the download... I added it because travis complained...
wget -nv https://www.riverbankcomputing.com/static/Downloads/sip/sip-$PYQTSIP_VERSION.tar.gz
tar -xvzf sip-$PYQTSIP_VERSION.tar.gz
cd sip-$PYQTSIP_VERSION
# add --verbose if more information needed
python configure.py --sip-module=PyQt5.sip
make -j $NP
sudo make install
echo "Done !"
cd ..
echo "=========== Install PyQt5 ==========="
# Remove -nv to have info on the download... I added it because travis complained...
wget -nv https://www.riverbankcomputing.com/static/Downloads/PyQt5/PyQt5_gpl-$QT5_VERSION.tar.gz
tar -xvzf PyQt5_gpl-$QT5_VERSION.tar.gz
cd PyQt5_gpl-$QT5_VERSION
# add --verbose if more information needed
LD_LIBRARY_PATH=$QT5_PATH/lib python configure.py --confirm-license --no-docstrings --no-designer-plugin --no-tools --enable=QtWidgets --enable=QtCore --enable=QtGui --enable=QtPrintSupport --enable=QtPositioning --enable=QtNetwork --enable=QtQuick --enable=QtQuickWidgets --enable=QtWebChannel --enable=QtQml --qmake=$QT5_PATH/bin/qmake QMAKE_LFLAGS_RPATH=
make -j $NP
sudo make install
echo "Done !"
cd ..
echo "=========== Install PyQtWebEngine ==========="
wget -nv https://www.riverbankcomputing.com/static/Downloads/PyQtWebEngine/PyQtWebEngine_gpl-$QT5_VERSION.tar.gz
tar -xvzf PyQtWebEngine_gpl-$QT5_VERSION.tar.gz
cd PyQtWebEngine_gpl-$QT5_VERSION
LD_LIBRARY_PATH=$QT5_PATH/lib python configure.py --qmake=$QT5_PATH/bin/qmake
make -j $NP
sudo make install
echo "Done !"
@rllola
Copy link
Author

rllola commented May 11, 2020

Hi!

I hope I can help.

I noticed you used python 2.7. I would recommend maybe going for python 3 if possible as python 2 is no longer supported since this year. In case you have to use python 2, you might be interested in this appveyor script that I had working for python 2.7 with Qt 5.12 for a project :

I believe your are on windows ? You will have to install Qt 5.12 first.

Note: you will notice that in qt 5.12, PyQtWebEngine has been separated from PyQt project. It is an extra that need to be installed.

Regarding your specific problem with qtwebengine_locales I remember I had this too but I believe I fixed it using a qt.conf file (https://github.com/rllola/ZeronetBrowser/blob/01786c896ebe6c73000a085a2f170a06ad2b1d00/qt.conf). However it wasn't working for all the version of Qt... like 5.11 was a bit broken. And I don't think I tried anything prior to Qt 5.10

I also had this ugly hack where I would copy some files in my build but not sure if it is relevant (which I removed when going for Qt 5.12) :
rllola/ZeronetBrowser@01786c8#diff-180360612c6b8c4ed830919bbb4dd459L48-L49

Here this all the information I can give you and that I can remember... Sorry it is a bit messy. Maybe something will work for you.

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