I am trying to run an older Python project that requires the PyQt4 library. When I run pip install PyQt4 in my terminal, I get a red error message saying "ERROR: Could not find a version that satisfies the requirement PyQt4 (from versions: none)". I have already tried upgrading pip and setuptools, but the error persists. Is there a specific Python version I need to be using, or is there a workaround to install this legacy GUI framework on a Windows 10 machine without using the standard repository?
3 answers
The core issue is that PyQt4 is no longer hosted on PyPI for modern Python versions (3.5 and above). The developers stopped supporting it years ago in favor of PyQt5 and now PyQt6. If you absolutely must use PyQt4, you generally have two options. First, you can try to find an archived "wheel" file (.whl) from a trusted third-party repository like Christoph Gohlke's archive and install it locally using pip install name_of_file.whl. Alternatively, you can install an older version of Python, such as 2.7 or 3.4, where PyQt4 was still natively supported. However, the most recommended path in modern software development is to refactor the code to use PyQt5, as the syntax is very similar but the library is actively maintained and compatible with the latest Python releases.
Are you tied to PyQt4 because of a specific legacy dependency that won't work with PyQt5, or are you just following an older tutorial that hasn't been updated to reflect the current state of the Python ecosystem? I ask because if it's just a tutorial, you can usually swap out from PyQt4 import ... with from PyQt5 import ... and the majority of your code will work perfectly with very minor adjustments.
You must match the architecture exactly. If you have 64-bit Python, you need a 64-bit PyQt4 wheel. If they don't match, you'll get a "not a supported wheel on this platform" error.
Susan is exactly right. To add to that, I highly recommend using a Virtual Environment (venv) for this. Since you are messing with legacy binaries, you don't want to break your main Python path. Richard, try creating a specific environment for this old tool so it doesn't conflict with your modern projects!
Thomas, I'm actually trying to maintain a research tool built back in 2014. It uses some specific Qwt widgets that were never fully ported to the newer versions. If I decide to go with the archived wheel file approach that Barbara mentioned, do I need to worry about binary compatibility with my 64-bit Python installation, or are those wheels generally universal across different processor architectures?