Compiling for CentOS 7

Marcus Ottosson edited this page Mar 9, 2017 · 2 revisions

This guide provides basic instructions on getting PyQt5 compiled on CentOS 7 for Python 2.7

Installation

  1. Install Qt
# First turn the newly downloaded file into an executable
$ chmod +x qt-unified-linux-x64-2.0.5-online.run
$ ./qt-unified-linux-x64-2.0.5-online.run
  1. Install Dependencies
# Install C++ compiler for Make
$ yum groupinstall 'Development Tools'

# Install Python source
$ yum install python-devel

# (Optional) Install OpenGL headers, for QtGui and QtWidgets
$ yum install freeglut-devel
  1. Compile SIP
tar -xf sip-4.19.1.tar.gz 
cd sip-4.19.1
$ python configure.py
$ make
$ sudo make install
  1. Compile PyQt
cd ..
tar -xf PyQt5_gpl-5.8.tar.gz
cd PyQt5_gpl-5.8

# This takes a minute or two.
#
# --qmake: Tell compiler about location of Qt binaries
$ python configure.py --qmake ~/Qt/5.8/gcc_64/bin/qmake

# Now we can run make.
# Note: This could potentially take an hour or two.
$ make -j4

# This takes less than a minute
$ sudo make install

Testing

PyQt should now be accessible from the version of Python you first ran configure.py with.

>>> import sys
>>> from PyQt5 import QtWidgets
>>> app = QtWidgets.QApplication(sys.argv)
>>> button = QtWidgets.QPushButton("Hello, World!")
>>> button.setFixedSize(100, 50)
>>> button.show()
>>> app.exec_()

If this produces a new window with a single button in it, you're good to go!

If not, you can contact me at marcus@abstractfactory.io.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.