I have the following imports in my unittest code:

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import QtCore, QtGui, QtTest

When I run my unit test from the command line I get the error:

ImportError: cannot import name QtTest

QtCore and QtGui appear to load just fine. Can anyone help me figure out why QtTest is different?

I'm running on a Mac OS X 10.10.5. QGIS 2.8.3. Python 2.7.10. I believe or at least hope is the Python bundled with QGIS. PyQt 4.11.3.

  • 1
    Just for info, I just tried the same operation on Ubuntu 14.04 64 bits with QGIS 2.12.2 and it does not fail ( in QGIS Python console like directly from command line) So, it seems related to your Mac installation or configuration. Normally, you should find a QtTest.so file somewhere. Do you have it?
    – ThomasG77
    Feb 2 '16 at 21:36
  • Thanks. I did in fact find a QtTest.so. It is installed with the pyqt installed by homebrew, but not in my QGIS install of pyqt. I am trying to update my PYTHONPATH to point to the brew installed version of pyqt. Feb 3 '16 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.