PyQt 4.5.4 for Python 2.6 amd64
Recently I've written an interface for the first time with PyQt4 in Linux for one of our pipeline related scripts. It was working very well under Linux, until I decided to check how it is going to look under Windows x64.
Well, it didn't take too long for me to recognize that there is no PyQt4 for Python 2.5 amd64. So I decided to compile my own. By the way you will see that I started for Python 2.5 but compiled for Python 2.6, it is just because, in a panic mode I've installed Maya 2010 to see if the package I found for PyQt4 for Python 2.6 amd64 for Windows x64 will work under. But no it wasn't ( actually it was, but I didn't know that I should add the path that contains the Qt DLLs to environment path ). So I dived in to compiling PyQt4 for Python2.6 amd64 for Windows x64.
Here you can find the How-To of that compilation...
You need these packages and programs:
MS Visual Studio 2008
Python 2.6 amd64
Qt 4.5.2 SDK for Windows
Sip 4.8.2 Source
PyQt4 4.5.4 Source
Nullsoft scriptable install system
Lets start:
- Install Python 2.6.2 amd64:
- install it to C:\Python2.6
- if you have already installed it somewhere else, in the rest of this "how-to" use that path instead of C:\Python26
- compile sip:
- download sip-4.8.2.zip
- unzip sip-4.8.2.zip to C:\sip-4.8.2
- open up the Visual Studio 2008 x64 Win64 Command Prompt from start menu/programs/etc.
- run the commands below
- cd C:\sip-4.8.2
- C:\Python26\python configure.py -p win32-msvc2008
- nmake
- nmake install
- open the python interpreter and check the module by using:
from sip import *
print SIP_VERSION_STR
if it doesn't give any error messages about a DLL or something, it is installed correctly - compile Qt4:
- download Qt SDK for Windows
- install it to C:\Qt\4.5.2 not to 2009.03
- delete the two tmp files: (they were causing problems in the middle of the compile process, very annoying to start again)
C:\Qt\4.5.2\qt\src\3rdparty\webkit\WebCore\tmp\moc\{debug,release}_shared/mocinclude.tmp) - open up the Visual Studio 2008 x64 Win64 Command Prompt
- run the commands below
- cd C:\Qt\4.5.2\qt
- set QTDIR=C:\Qt\4.5.2\qt
- set PATH=%PATH%;C:\Qt\4.5.2\bin
- configure -opensource -platform win32-msvc2008
- enter "y" for the question
- nmake ( and go to have a lunch or dinner, seriously, it took 3 hours in my computer, it will be around on yours too )
- nmake install
- congratulations you have built Qt4 x64 for Windows x64
(NOTE 1: you can create a batch file that runs the 'configure' then the 'nmake' and then the 'nmake install' commands, but when you run this batch file wait for 1 seconds to the question in configure step then leave :) )
(NOTE 2: because we didn't specified a -prefix option in configure, it will compile it over the source directories ) - compile PyQt4:
- download PyQt4 4.5.4 Source
- unzip the PyQt4 source to C:\PyQt-win-gpl-4.5.4
- open Visual Studio 2008 x64 Win64 Command Prompt
- run the commands below
- set QTDIR=C:\Qt\4.5.2\qt
- set Path=%PATH%;C:\Qt\4.5.2\qt\bin\
- cd C:\PyQt-win-gpl-4.5.4
- C:\Python26\python configure.py -w
- enter "yes" to the question
- nmake ( again it takes some time )
- nmake install
- now you should be able to use PyQt4, but if there is an error message saying:
Python 2.6.2 (r262:71605, Apr 14 2009, 22:5+:60) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or license" for more information.
>>> from PyQt4 import QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found
>>>
you need to add the folder that contains Qt DLLs to the environment path variables, by using the Control Panel -> System -> Advanced -> Environment Variables - Nullsoft installer to make installable binary package:
- download and install Nullsoft installers latest version
- right click C:\PyQt-win-gpl-4.5.4\PyQt.nsi and select "Compile NSIS Script"
( unfortunatelly the script gives a lot of errors, you need to copy/paste some files and create folders by your self according to the complains of the compiler )
for Python 2.5, compiling PyQt4 for Python 2.5 x64 is quite similar, you just need to use vs2005 and its x64 command prompt compiler with the nearly the same commands, just replace win32-msvc2008's with win32-msvc2005, that's all...
EDIT 1:
for Python 2.6 version of PyQt4 you need to install Microsoft Visual C++ 2008 SP1 Redistributable Package (x64) also
for Python 2.5 version of PyQt4 Microsoft Visual C++ 2005 SP1 Redistributable Package (x64) also
EDIT 2:
I've compiled the Python 2.5 amd64 version of PyQt4 for Windows x64... Download (the Phonon Multimedia Framework is only supported by python 2.6 an later)