UPDATE:
The original post is from 2010 and since then the world has moved on. At the time of writing this update python27 is a default python version for Ubuntu. This means that to get PyQt and python27 running you no longer have to build PyQt from source. You can just install PyQt using apt-get:
I am keeping the original post in case you do need to build it from source (for example if you are using virtualenv, python3 or you are actually not using Ubuntu but a distribution that does not have a prepackaged PyQt).
ORIGINAL POST:
This tutorial shows how to build and install PyQt4 with python2.7 in Ubuntu.
If you want to use it with different version of python than 2.7 than replace every 2.7 in instructions below with the version you are using and it should work (tested with 2.6 and 3).
First, you need some prerequities:
Then, try to install the PyQt and SIP using pip (it fails but it downloads the required packages to your ~/build/ folder).
After that go to ~/build/SIP and install it
Finally go to ~/build/PyQt and install it
Note: as PyQt is a big project - building it may take some time..
And that's all. You can test it by trying to import QtCore in python2.7
If there is no import error - you have PyQt4 installed correctly!
The original post is from 2010 and since then the world has moved on. At the time of writing this update python27 is a default python version for Ubuntu. This means that to get PyQt and python27 running you no longer have to build PyQt from source. You can just install PyQt using apt-get:
sudo apt-get install python-sip python-qt4
I am keeping the original post in case you do need to build it from source (for example if you are using virtualenv, python3 or you are actually not using Ubuntu but a distribution that does not have a prepackaged PyQt).
ORIGINAL POST:
This tutorial shows how to build and install PyQt4 with python2.7 in Ubuntu.
If you want to use it with different version of python than 2.7 than replace every 2.7 in instructions below with the version you are using and it should work (tested with 2.6 and 3).
First, you need some prerequities:
sudo apt-get install python-pip python2.7-dev libxext-dev python-qt4 qt4-dev-tools build-essential
Then, try to install the PyQt and SIP using pip (it fails but it downloads the required packages to your ~/build/ folder).
pip install PyQt
pip install SIP
After that go to ~/build/SIP and install it
cd ~/build/SIP
python2.7 configure.py
make
sudo make install
Finally go to ~/build/PyQt and install it
Note: as PyQt is a big project - building it may take some time..
cd ~/build/PyQt
python2.7 configure.py
make
sudo make install
And that's all. You can test it by trying to import QtCore in python2.7
python2.7
>>> from PyQt4 import QtCore, QtGui
If there is no import error - you have PyQt4 installed correctly!