PyQt4 no install

Good morning
My name is Stéphane, I am trying to operate a mouse via the webcam. For that I found this tutorial which works with python.

On my computer, macOS Ventura, I have python version 3.8. installed.

To be able to move the mouse with my head, I followed this tutorial which asks me to launch a file named

The problem is that if I run the file named in my terminal I get this error

Traceback (most recent call last):
  File "", line 10, in <module>
    from PyQt4 import QtCore, QtGui, uic
ModuleNotFoundError: No module named 'PyQt4'

So I tried to install PyQt4, but I have this error message!

ERROR: Could not find a version that satisfies the requirement PyQt4 (from versions: none)
ERROR: No matching distribution found for PyQt4

Currently I have to install

PyQt5                                             5.15.9
PyQt5-Qt5                                         5.15.2
PyQt5-sip                                         12.11.1

How do I make my file work? Thanks in advance


PyQt4 has been unmaintained for many years, and is not compatible with modern Python; you should use PyQt5 or PyQt6 instead, especially when starting fresh with a new project. If you are following a tutorial for it, I strongly suggest you just find a more up to date tutorial—and I’m sure you can find a lot better than a one with no narration or explanation from a channel with 34 subscribers.

If you do want to try to make this work, you’ve apparently already installed PyQt5, so you could try replacing PyQt4 with PyQt5 in your import statement as QtCore, QtGui and uic are still available and the basics should mostly still work the same. However, if it does anything non-trivial, you’re likely to run into issues that may or may not be easy for a beginner to solve, so again I would strongly recommend finding a more up-to-date tutorial for PyQt5/6 or PySide2/6 5.12/6.2 or above.

Also, just to note, since these questions are about Qt//PyQt and not the Python language itself, you’re likely to find better help on a Qt/PyQt-specific forum. Best of luck!

That’s what I did, change version four to five in the code. The problem is that now other errors are displayed

Traceback (most recent call last):
  File "", line 60, in <module>
    Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyQt5/uic/", line 203, in loadUiType
    winfo = compiler.UICompiler().compileUi(uifile, code_string, from_imports,
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyQt5/uic/Compiler/", line 111, in compileUi
    w = self.parse(input_stream, resource_suffix)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyQt5/uic/", line 1020, in parse
    document = parse(filename)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/xml/etree/", line 1202, in parse
    tree.parse(source, parser)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/xml/etree/", line 584, in parse
    source = open(source, "rb")

In order to just do a test, can you tell me with which python version worked PyQt4 ?

The error message above is incomplete (there should be at least one more line below in the traceback that was omitted), so I can’t say for sure what the error was, but it is almost certainly due to compatibility differences between PyQt4 and PyQt5. I am one of the maintainers of the QtPy package, which provides a compability layer between different versions of PyQt and PySide, but even we dropped support for PyQt4 years ago because it was long-obsolete and few people were left using it.

As far as I can tell, PyQt4 isn’t even on PyPI anymore (if it ever was), so you can’t (easily) install it with pip on any version of Python (AFAIK; both PyQt4 and Qt4 been discontinued since around the time I myself started learning Python). I found some old third-party packages but they were only compatible with up to Python 3.7, which is itself reaching the end of its extended support lifecycle.

Therefore, as I mentioned previously, your best bet is to look for tutorials doing something similar using a less ancient version of PyQt, and then if you really want to complete the particular project in that one, coming back to that one once you’ve picked up enough skills to understand the code and modernize it where necessary to work with a non-obsolete/end of life version of PyQt5/6 and Python. Shameless plug, but QtPy (which I’m one of the maintainers of) is a compatibility layer that might help you in that regard.

Best of luck!

Its there at PyQt4 · PyPI but don’t expect any support from up stream.
Its last release was 8 years ago…

Right, I saw that, but there aren’t actually any files on PyPI; it instead links to Riverbank’s download page where it can be downloaded manually. It was so long ago that back in the day, PyPI used to do that for packages but discontinued it not long after that.

Ok, thank you for your answers. I will try to contact the person who developed this code and see if he can update it but it is not won lol. thanks anyway