Compiling PyQt5 on Ubuntu 12.04 konopczynski edited this page on 22 Nov 2016 · 21 revisions Pages 9

Compiling PyQt5 on Ubuntu 12.04

konopczynski edited this page  on 22 Nov 2016  ·   21 revisions

Welcome to the wiki for PyQt5 using Python 2.7. For Python 3.4, head here

Table of contents

Developer Resources

Compilation Instructions

Clone this wiki locally

This guide provides basic instructions on getting PyQt5 compiled on Ubuntu 12.04 x64 for Python 2.7

Prerequisites

To complete this compilation, there are three files which you'll need.

  1. Qt 5.3.1
  2. sip-4.16.5
  3. PyQt 5.3.2

Tested with Qt 5.3.1 and 5.4.1.

Installation

  1. Install Qt

image

# First turn the newly downloaded file into an executable
$ chmod +x qt-opensource-linux-x64-5.3.1.run
$ ./qt-opensource-linux-x64-5.3.1.run
  1. Install Dependencies
# Install C++ compiler for Make
$ sudo apt-get install build-essential

# Install Python source
$ sudo apt-get install python-dev

# Install PyQt-specific libraries for Ubuntu
$ sudo apt-add-repository ppa:ubuntu-sdk-team/ppa
$ sudo apt-get update
$ sudo apt-get install qtdeclarative5-dev
  1. Compile SIP
$ tar xvzf sip-4.16.5.tar.gz
$ cd sip-4.16.5
$ python configure.py
$ make
$ sudo make install
  1. Compile PyQt
$ cd ..
$ tar xvzf PyQt-gpl-5.3.2.tar.gz
$ cd PyQt-gpl-5.3.2

# This takes a minute or two.
#
# --qmake: Tell compiler about location of Qt binaries
# --sip-incdir: Tell compiler about location of sip library
$ python configure.py --qmake ~/Qt5.3.1/5.3/gcc_64/bin/qmake --sip-incdir ../sip-4.16.5/siplib

# The PyQt makefile assumes the Python libraries that we just installed
# to be located in a different location than what Ubuntu has chosen to
# store them. We'll symlink the actual location into the assumed location.
$ sudo ln -s /usr/include/python2.7 /usr/local/include/python2.7

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

# 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.

References
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值