SaltyCrane Blog — Notes on JavaScript and web development

How to install pyqt4 on ubuntu linux

Install and run "hello world" example
  • apt-cache search pyqt
  • sudo apt-get install python-qt4
  • Create a file ~/tmp/
    import sys
    from PyQt4.QtGui import *
    app = QApplication(sys.argv)
    button = QPushButton("Hello World", None)
  • Run it:
    python ~/tmp/
    You should see a window with a single button pop up.

Install additional examples
  • For more examples, install the python-qt4-doc package:
    sudo apt-get install python-qt4-doc
  • After installation, the examples are located at:


#1 pamchi commented on :

And then??? i do that but it doesn't work... :( what can i do?

#2 Eliot commented on :

I've update the post to include some more information. Good luck!

#3 B commented on :

it's somewhat odd, but it seems like the python-qt4 package is missing some parts. specifically, I've run into two so far: setTimeSpec from QDateTimeEdit and setHeaderHidden from QTreeView. Both of these are in the docs, so I guess to use them you need to do a manual install? Unless the next release fixes this.

#4 Eliot commented on :

B, the python-qt4 package in Ubuntu Hardy provides PyQt 4.3. However, currently, the latest version is PyQt 4.4. You were probably looking at the docs for 4.4. To get the latest version, you can install it manually (I don't think it is very hard). Or, if you can wait a month, Ubuntu Intrepid will include PyQt 4.4.

#5 Robert commented on :

I'm trying to get Thin Liquid Film running on my Intrepid Ibex installation. However, when I try installing it, it tells me that I'm missing pyqt.

I loaded Synaptic and have installed the python-qt4 package (version 4.4.3-1ubuntu1) which includes the libqtcore package version 4.4.3-0ubuntu1 and python-bindings version 4.4.3-1ubuntu1.

Any ideas why its not installing?


#6 Robert commented on :

Answering my own question. Apparently TLF is specifically looking for QT3. Guess they haven't updated their program as of yet.

#7 trish commented on :

It worked fine for me. Great example of a small qt program. i am impressed.

#8 Pradeep commented on :

Hii I am have suffering few problems in doing following assignment , please help me...

Qtprogram using python to calculate addition, subtraction.

please help me ...i am new in python

email id:[email protected]

#10 Anwar Ahmed commented on :

thanks , it was quick to find and simple.

#11 Umid commented on :

On my ubuntu box, there are python2.6 and python3.1

When I installed PyQt4 it works for python2.6.

How to configure it for python3.1 too?

#12 yanghaipo commented on :

Thanks, this is really a good example.

#13 AA commented on :

After trying, the follow appears:

Depende: libqt4-designer (>= 4:4.7.0) mas não vai ser instalado Depende: libqt4-help (>= 4:4.7.0) mas não vai ser instalado Depende: libqt4-scripttools (>= 4:4.7.0) mas não vai ser instalado Depende: libqt4-test (>= 4:4.7.0) mas não vai ser instalado Depende: libqtassistantclient4 (>= 4.6.3) mas não vai ser instalado Depende: sip-api-8.1

After trying to install libqt4 it appears:

Depende: python-qt4 (>= 4.4) mas não vai ser instalado Depende: python-sqlalchemy (>= 0.4.3) mas não vai ser instalado Depende: python-beautifulsoup mas não vai ser instalado Recomenda: python-matplotlib mas não vai ser instalado

So, basically, one depends on the other, and none will install...

Thank you for the tips though...

#14 George Van Tuyl commented on :

Worked just fine thank you. Ubuntu 11.1 Wheezy/sid 3.0.0-14-generic-pae i686


#15 Juuso commented on :

If you are looking for pyqt designer, you should also add: apt-get install libqt4-dev qt4-dev-tools python-qt4-dev pyqt4-dev-tools

#16 ken brockman commented on :

I have been trying unsuccessfully on and off for over three months to get eric5 installed on my Ubuntu 11.10 system. Each time I try to compile it, i get the same error msg, "Qthelp not found". I have python2.7 and 3.2 and 3.2mu installed. When i install I have referenced python, python3.2 and python3.2mu, all to no avail. Any help would be greatly appreciated. Tkinter is looking better by the day, though I would really love to use QT and eric5. If I try using apt-get install, it says already installed because they are, for 2.7, but not 3.2. I have BUILT MAKE INSTALLED the QT downloads several times along with SIP, Pyqt, pyside and several other apps, but once again,, nada. I am starting to think it can't be done. in all of my 30 plus years of using building and repairing computers, I have never, ever seen anything as convoluted and aggravating as this. For the love of God if anyone, anywhere has any idea of how to get this %^$&$ thing to work, PLEASE,, let me know...

#17 Anthony Scaife commented on :

Quick and easy advice, thanks. Worked first time for me. Ubuntu 10.04.

#18 Ha Thanh commented on :

Yes, it worked for me. Ubuntu 11.10.

Many Thanks!

#19 paython commented on :

We do not need to install sip before install pyqt?

#20 Diego commented on :

Thanks for this help.

#21 chm commented on :

In the latest version of PyQt,The code above should be changed,or we will get "NameError: global name 'argv' is not defined "

#22 Sanjeev commented on :

google is great and your blog is even greater

#23 Ammar Atef commented on :

Why there is no relation between the app and the button? should be only one app in the code? what does it represent?