DAGDA SEARCH | Back to results | Support

Build PyQt4 Windows - Python Wiki

Source: https://wiki.python.org/python/archive/BuildPyQt4Windows.html

  1. Python Wiki /
  2. Python Wiki /
  3. Archive /
  4. Build PyQt4 Windows
View as Markdown

Build PyQt4 Windows

Legacy Wiki Page

This page was migrated from the old MoinMoin-based wiki. Information may be outdated or no longer applicable. For current documentation, see python.org.

The No-fuss Guide to Building PyQt on Windows XP

Date:

2007-07-11

Author:

Martin Blais <blais@furius.ca>

Abstract

This document contains instructions on building PyQt under Windows, using the pre-built binary version of Qt installed via its installer.

Introduction

Typically, you want to built the PyQt snapshots when it is lagging a little bit behind the Qt release. When I wrote this document, I wanted to build PyQt for Qt-4.3.3 and there was no binary at that time.

See this thread for more details: http://www.mail-archive.com/pyqt%40riverbankcomputing.com/index.html#11081

Note: follow these instructions to-the-letter. This is Windows. Any slight variation might throw you off.

Versions

This document is up-to-date for the following versions:

Detailed Instructions

Installing Qt

This will place Qt in C:\Qt\<version> by default.

Installing Python

Installing MinGW

You will need an install of MinGW that contains mingw32-make.exe. Install MinGW using the binaries from the MinGW website. I placed mine in C:\MinGW.

Setting up for Build

You MUST use the cmd.exe shell, and not Cygwin’s bash nor MinGW nor MKS not anything else.

Start cmd.exe and set your PATH to something clean that contains both MinGW and Qt:

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Qt\4.3.3\bin;C:\MinGW\bin

Verify your PATH configuration by running these two commands:

g++ -v
qmake -v

Building and Installing SIP

This should install the following files in your Python library:

C:\Python25\include\sip.h
C:\Python25\Lib\site-packages\sip.pyd
C:\Python25\Lib\site-packages\sipconfig.py
C:\Python25\Lib\site-packages\sipconfig.pyc
C:\Python25\Lib\site-packages\sipdistutils.py
C:\Python25\sip.exe

Building and Installing PyQt

Using the same shell setup as above,

This should install the following files:

C:/Python25
C:/Python25/Lib/site-packages
C:/Python25/Lib/site-packages/PyQt4
C:/Python25/Lib/site-packages/PyQt4/pyqtconfig.py
C:/Python25/Lib/site-packages/PyQt4/Qt.pyd
C:/Python25/Lib/site-packages/PyQt4/QtAssistant.pyd
C:/Python25/Lib/site-packages/PyQt4/QtCore.pyd
C:/Python25/Lib/site-packages/PyQt4/QtDesigner.pyd
C:/Python25/Lib/site-packages/PyQt4/QtGui.pyd
C:/Python25/Lib/site-packages/PyQt4/QtNetwork.pyd
C:/Python25/Lib/site-packages/PyQt4/QtOpenGL.pyd
C:/Python25/Lib/site-packages/PyQt4/QtScript.pyd
C:/Python25/Lib/site-packages/PyQt4/QtSql.pyd
C:/Python25/Lib/site-packages/PyQt4/QtSvg.pyd
C:/Python25/Lib/site-packages/PyQt4/QtTest.pyd
C:/Python25/Lib/site-packages/PyQt4/QtXml.pyd
C:/Python25/Lib/site-packages/PyQt4/uic
C:/Python25/Lib/site-packages/PyQt4/uic/Compiler
C:/Python25/Lib/site-packages/PyQt4/uic/Loader
C:/Python25/Lib/site-packages/PyQt4/uic/widget-plugins
C:/Python25/Lib/site-packages/sip.pyd
C:/Python25/Lib/site-packages/sipconfig.py
C:/Python25/Lib/site-packages/sipconfig.pyc
C:/Python25/pylupdate4.exe
C:/Python25/pyrcc4.exe
C:/Python25/pyuic4.bat
C:/Python25/sip
C:/Python25/sip/PyQt4
C:/Python25/sip/PyQt4/Qt
C:/Python25/sip/PyQt4/Qt/Qtmod.sip
C:/Python25/sip/PyQt4/QtAssistant
C:/Python25/sip/PyQt4/QtCore
C:/Python25/sip/PyQt4/QtDesigner
C:/Python25/sip/PyQt4/QtGui
C:/Python25/sip/PyQt4/QtNetwork
C:/Python25/sip/PyQt4/QtOpenGL
C:/Python25/sip/PyQt4/QtScript
C:/Python25/sip/PyQt4/QtSql
C:/Python25/sip/PyQt4/QtSvg
C:/Python25/sip/PyQt4/QtTest
C:/Python25/sip/PyQt4/QtXml

Test It

Run Python and import PyQt4 to test it:

C:\tmp\PyQt-win-gpl-4-snapshot-20070710>C:/Python25/python
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt4.Qt import *
>>> from sip import *
>>> print SIP_VERSION_STR, QT_VERSION_STR, PYQT_VERSION_STR
PreviousBuild an Intranet Next Build Statically