All components that combine to form a PyQt development environment are also freely available. Python, Qt, Qt Designer, sip, PyQt and editors are all available as open source. If you use Linux—and particularly if you use a modern and complete distribution like SuSE or Redhat—everything you need is included on your distribution media, including PyQt. There are also Debian packages of PyQt available. Installing these ready-made packages is very easy, but they are not always completely up-to-date. In the next section, I will discuss building PyQt from source, which is necessary if you want to always run the latest version of PyQt.
Windows users who want to use PyQt without BlackAdder have some downloading to do, but all components are available as binary packages that come with easy to use Windows installers.
Installing PyQt from source on Windows falls outside the scope of this book, partly because it is quite complicated, and partly because I don't have a C++ compiler for Windows. The Qt library essentially demands Visual C++.
You can also access the PyQt CVS repository (the central place where the most current code is kept — also at http://www.thekompany.com). Compiling PyQt from CVS source entails creating the C++ bindings code from the sip definition files, and then carrying on as if you had downloaded the source. Keep in mind that CVS versions of software are not expected to work!
Assuming you already have an installation of Python and Qt, you first need to gather the following packages if you want to build PyQt from source:
Be careful to choose versions of packages that fit each other. You can compile PyQt with most versions of Qt, but Python 2.1 will give better results than Python 2.0, and so on.
You need to compile and install sip before compiling PyQt. After unpacking the sip tar archive, you will need to give the following commands:
boud@calcifer:~/src/sip-2.5 > ./configure; make
And, when building is complete, become superuser and type:
root@calcifer:/home/boud/src/sip-2.5 > make install
If your Python or Qt installation is in an odd place, then chances are that the configure script cannot find it. In that case, you should give their locations on the command line:
boud@calcifer:~/src/sip-2.5 > ./configure \ --with-qt-dir=/opt/qt \ --with-python=/usr/local/bin/python
This will build the sip library and executable, and install them (most likely in /usr/local/). With this done, it is time to do the same with PyQt. This time, the make command will take a long time to run, because PyQt is a very large set of bindings, and the GNU C++ compiler isn't the fastest around.
boud@calcifer:~/src/PyQt-2.5 > ./configure; make ... boud@calcifer:~/src/PyQt-2.5 > su Password: root@calcifer:/home/boud/src/PyQt-2.5 > make install
The whole process might take a while, but should not pose any problem. Sometimes, however, things go wrong...
While not really difficult, compiling from source is an exercise to be attempted only by the technically adept. Certain problems have cropped up throughout the life of PyQt, only to be solved in later versions. Other problems have been caused by the version of the GNU C++ compiler used in certain releases of Redhat: gcc 2.96.
If you are experiencing problems, you probably have several versions of Python or Qt on your system, and the compilation configuration process inevitably picks the wrong one — for instance Qt 2.3.1 for sip and then Qt 3.0.0 for PyQt. Murphy's law cannot be avoided! This hurts compilation — but is easily avoided by giving the right versions at the ./configure command line.
If you have determined that this is not the problem, your best bet will be to subscribe to the PyQt mailinglist: http://mats.gmd.de/mailman/listinfo/pykde, where most of us have found succor more than once.
You can develop applications on Windows systems with PyQt using only gratis software. Life will certainly be more difficult than if you buy BlackAdder, because you miss the nice integration of editor, debugger and operating system. Another issue is licensing: if you buy the professional edition of BlackAdder, you can write commercial software. If you use the non-commercial version of the Qt library and the separately available packages of sip and PyQt, you are not allowed to sell your programs: you are not even allowed to use your software yourself in a commercial setting. However, if you want to develop PyQt on windows without spending any money, you need the following components:
The Non-commercial licensed Qt library from http://www.trolltech.com. This a full version of Qt. You cannot build commercial applications with this library, and you cannot use your software in a commercial setting. Additionally, you must make the source to your software available. See http://www.trolltech.com/products/download/freelicense/noncommercial-dl.html for more information.
You also need the precompiled PyQt for Windows library from http://www.thekompany.com/projects/pykde/. This is made available under the same license as the non-commercial version of Qt. You don't need to download a separate copy of sip.
Of course, Python is needed, too! Get it from http://www.python.org.
You also need a nice editor to type your Python code with. notepad just won't do - SciTE, which uses the same editor component as BlackAdder, is very powerful and pleasant to use. Get SciTE from http://www.scintilla.org/SciTE.html. (SciTE is also available for Linux.)
The SciTE editor.
You job is then reduced to manually installing Python, Qt, PyQt, and an editor. Then you can get started on developing your application.