PyQt Import Error

14,275

PyQt installation also depends on the version of python installed on your platform.Python3.+ is incompatible with Python version < 3.x.

I was facing the same problem as I have Python 2.7 installed on my machine but I downloaded the latest binary which was PyQt-Py3.2-x86-gpl-4.9.exe. If you see here the binary has python version also mentioned in name after PyQt which is Py3.2. I uninstalled PyQt and installed PyQt-Py2.7-x86-gpl-4.9.exe which points to Python 2.7 and it fixed the problem.

Probably they could have mentioned the naming convention online or in some documentation to be more simpler.

Share:
14,275
Byron
Author by

Byron

Updated on July 15, 2022

Comments

  • Byron
    Byron almost 2 years

    I have a very simple PyQt program

    import sys
    from PyQt4.QtGui import *
    
    app = QApplication(sys.argv)
    
    widget = QWidget()
    widget.show()
    
    sys.exit(app.exec_())
    

    When I double click to run the program, it runs successfully. But when I run it in command line: python test.py, I got the following error

    Traceback (most recent call last):
      File "test.py", line 2, in <module>
        from PyQt4.QtGui import *
    ImportError: No module named PyQt4.QtGui
    
  • Byron
    Byron almost 13 years
    Thanks SeeJay. I solved the problem by removing the duplicated python interpreter from the PATH
  • Sam Kauffman
    Sam Kauffman over 9 years
    I've got the same problem. I downloaded PyQt5-5.2.1-gpl-Py3.3-Qt5.2.1-x64 but it didn't work with Python 2.7. I couldn't find an appropriate PyQt5 installer for Python 2. Is there one? Do I need to build from source? Or do I need to use PyQt4 instead? PyQt5 is supposed to be compatible with Python 2.6+.