Issue
Is there some reason that QtGui is packaged with PyQt5???
I am using Mark Summerfield's Rapid GUI programming book. Obviously this book was written with Qt4 in mind, but I have been recommended to use Qt5, and PyQt5. I want to run the first example code in chapter 4. The code begins with the following import statements:
import sys
import time
from PyQt5.QtCore import *
from PyQt5.QtGui import *
To which the compiler responds:
Traceback (most recent call last):
File "wakeUp.py", line 4, in <module>
from PyQt5.QtGui import *
ImportError: No module named 'PyQt5.QtGui'
Note that the PyQt5.QtCore import statement does not generate an error.
From the terminal,
$ echo $PYTHONPATH
:/usr/lib/python3.3/site-packages
Has anybody else come across this import error for QtGui?
From an interactive session I can
>>> import PyQt5.Qt
>>> import PyQt5.QtDBus
>>> import PyQt5.QtNetwork
>>> import PyQt5.QtXmlPatterns
But I don't have QtWidgets, QtGui, QtWebkit, QtDesigner, and several others.
Also, if it is helpful, the contents of /usr/lib/python3.3/site-packages/PyQt5 are:
__init__.py QtCore.so QtDBus.so QtNetwork.so Qt.so QtXmlPatterns.so uic
which are the same modules that I am able to import. Should the other modules (QtWidgets, QtGui etc) be here too?
I am using Ubuntu 13.04 and Python 3.3.
Solution
The problem was when I was running the PyQt5 configure script. The correct option to pass went like this:
> python3 configure.py --qmake [path to Qt5.x]/bin/qmake
I was providing the path up to bin, but did not specifically point to qmake. Go figure!
After running the configure script like this, I was able to import all the PyQt5 modules.
Answered By - ADB
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.