[PyQt] Re: PyQt Digest, Vol 46, Issue 34

Wade Spires wspires at cs.ucf.edu
Sat May 17 23:34:40 BST 2008


> On Saturday 17 May 2008 15:05:07 Wade Spires wrote:
>> Hi,
>>
>> I am new to pyqt development.  I am trying to just run some of the
>> example programs but am getting this import error:
>>   PyQt-x11-gpl-4.4 # ./examples/tutorial/t1.py
>>   Traceback (most recent call last):
>>     File "./examples/tutorial/t1.py", line 6, in ?
>>       from PyQt4 import QtGui
>>   ImportError: cannot import name QtGui
>>
>> It looks like PyQt is installed:
>>   PyQt-x11-gpl-4.4 # ls /usr/lib64/python2.4/site-packages/PyQt4/
>>   elementtree/   QtAssistant.so*  QtGui.so*      Qt.so*     QtTest.so*
>>   __init__.py    QtCore.so*       QtNetwork.so*  QtSql.so*  QtXml.so*
>>   pyqtconfig.py  QtDesigner.so*   QtOpenGL.so*   QtSvg.so*  uic/
>>
>> I tried setting my PYTHONPATH and LD_LIBRARY_PATH environment
>> variables to include /usr/lib64/python2.4/site-packages and
>> /usr/lib64/python2.4/site-packages/PyQt4/ respectively, but this did
>> not solve the problem.  I can import PyQt4 itself, but it doesn't seem
>> to have any modules available such as QtGui or QtCore.
>>
>> Any idea on what the problem is and how to solve it?  I apologize if
>> such a simple problem has already been answered, but I didn't see it
>> in the archive.
>
> Permissions on the .so files?
>
> Phil

That was it!  Thanks for the help Phil.  I'm glad that it was such an easy fix.

In case anyone else needs help with this, this is what I did.
Check the permissions:
  # ls -l /usr/lib64/python2.4/site-packages/PyQt4/
  drwxr-xr-x 2 root root    4096 May 16 22:56 elementtree/
  -rw-r--r-- 1 root root    1619 May 17 00:04 __init__.py
  -rw-r--r-- 1 root root   12684 May 17 00:04 pyqtconfig.py
  -rwxr-x--- 1 root root   21584 May 17 00:04 QtAssistant.so*
  -rwxr-xr-x 1 root root 1676672 May 17 00:04 QtCore.so*
  -rwxr-x--- 1 root root  398112 May 17 00:04 QtDesigner.so*
  -rwxr-x--- 1 root root 6854032 May 17 00:04 QtGui.so*
  ...
The shared objects are only readable and executable by root, so I
can't access them as my user.

Fix the permissions as root:
  # sudo chmod 755 /usr/lib64/python2.4/site-packages/PyQt4/*.so

Verify that the permissions have changed:
  # ls -l /usr/lib64/python2.4/site-packages/PyQt4/
  drwxr-xr-x 2 root root    4096 May 16 22:56 elementtree/
  -rw-r--r-- 1 root root    1619 May 17 00:04 __init__.py
  -rw-r--r-- 1 root root   12684 May 17 00:04 pyqtconfig.py
  -rwxr-xr-x 1 root root   21584 May 17 00:04 QtAssistant.so*
  -rwxr-xr-x 1 root root 1676672 May 17 00:04 QtCore.so*
  -rwxr-xr-x 1 root root  398112 May 17 00:04 QtDesigner.so*
  -rwxr-xr-x 1 root root 6854032 May 17 00:04 QtGui.so*
  ...

Now, make sure pyqt works:
  PyQt-x11-gpl-4.4 # ./examples/tutorial/t1.py
We see a window, yay!

Thanks,
Wade


More information about the PyQt mailing list