[PyQt] PyQt application frozen if run in localhost; OK if SSH'd to another host

Hans-Peter Jansen hpj at urpla.net
Thu Jun 23 20:42:34 BST 2011

On Thursday 23 June 2011, 18:26:52 Arrieta wrote:
> Consider the following PyQT application (helloworld.py):
> import sys
> from PyQt4 import QtGui
> def main():
>     app = QtGui.QApplication(sys.argv)
>     win = QtGui.QPushButton("Hello, World!")
>     win.show()
>     return app.exec_()
> if __name__ == "__main__":
>     sys.exit(main())
> If I run ($python helloworld.py) this application from a shell in my

It looks, like $python is some unusual shell variable, that we cannot 

> computer, I see the main container for the button, but the button
> itself never renders.

What happens, if you run python interactively, and paste the above into 
the python shell?

> After a few clicks on the [x] of the main 
> container, I receive a warning window stating:
> Window with title "helloworld.py" is not responding. This window
> belongs to application helloworld.py (PID=2000, hostname=localhost).
> Do you wish to terminate this application? (All unsaved data in this
> application will be lost.) [Yes] [No]

This is the window manager chiming in. For some reason, the 
communication to the X server seems to be stalled. xauth issues?

> If I then use the same shell window to SSH to another machine in our
> network and run the exact same program (we have an NFS file system; I
> see the same files in every machine) it runs as expected. In fact,
> even if I SSH back to my original computer I can run the application.

Well, ssh -X creates a private communication channel to the X server.

> This happens with all the PyQt applications I have developed for my
> group, and it happens on every computer in our network: the
> applications won't run locally, but run perfectly fine if the user is
> connected to the terminal via SSH (let me insist, even if SSH'd to
> your local, physical computer!)

I cannot see a single reason, how PyQt could be the culprit here.

The whole issue sounds like a major misconfiguration of X, selinux, or 
some other "security" feature running wild..

> Do you have any suggestion for debugging/tracking down this problem?

You might want to recode the script in C++. Due to the nature of PyQt, I 
expect this to fail in a similar way, or your PyQt build is busted in 
non trivial ways.

> Many thanks.
> Python 2.6.5
> Qt 4.6.2
> Red Hat Linux Enterprise Edition (4)

Since you asked here, you might want to tell us the versions of sip and 
PyQt you use. Even, if it happens that you discover the reason being 
something unrelated to sip/PyQt, report this back here, please.


More information about the PyQt mailing list