121

I'm using Python 3.4 on Windows. When I run a script, it complains

ImportError: No Module named 'PyQt4'

So I tried to install it, but pip install PyQt4 gives

Could not find any downloads that satisfy the requirement PyQt4

although it does show up when I run pip search PyQt4. I tried to pip install python-qt, which installed successfully but that didn't solve the problem.

What am I doing wrong?

2
  • 5
    just download it from here :riverbankcomputing.com/software/pyqt/download and run it using python. Mar 25, 2014 at 16:33
  • The python-qt package doesn't install PyQt: it's just a PySide/PyQt compatibility wrapper. You should do as thecreator232 suggests, and install the binary Windows package instead. However, you will need to downgrade to python-3.3 first, because there aren't any installers for python-3.4 yet.
    – ekhumoro
    Mar 25, 2014 at 19:48

14 Answers 14

164

Here are Windows wheel packages built by Chris Golke - Python Windows Binary packages - PyQt

In the filenames cp27 means C-python version 2.7, cp35 means python 3.5, etc.

Since Qt is a more complicated system with a compiled C++ codebase underlying the python interface it provides you, it can be more complex to build than just a pure python code package, which means it can be hard to install it from source.

Make sure you grab the correct Windows wheel file (python version, 32/64 bit), and then use pip to install it - e.g:

C:\path\where\wheel\is\> pip install PyQt4-4.11.4-cp35-none-win_amd64.whl

Should properly install if you are running an x64 build of Python 3.5.

7
  • 1
    is there is pip under linux or easy install ? Jan 24, 2015 at 13:41
  • 2
    For linux, it is best to install the development packages for Qt and PyQt from your package manager.
    – Ivo
    Feb 18, 2015 at 13:35
  • 7
    why is all the 64bit stuff amd based? It tells me that 64 bit amd version is not a supported wheel on "this platform"
    – Naz
    Apr 10, 2017 at 20:37
  • 10
    FWIW, with python 3.6 installing pyqt5 via pip install pyqt5 just works. Sep 28, 2017 at 22:28
  • 4
    The 64bit stuff is AMD-based, because Intel as well as AMD created their own (incompatible) 64bit architectures/instruction sets back then (1990s to early 2000s). Intel developed "IA-64" and AMD developed "AMD64". To make it short: AMD's version was better and Intel adopted it, now calling it Intel64 for their CPUs - both are pretty much compatible (very minor differences). So pretty much every 64bit x86-64 CPU out there (except Itaniums) uses AMD64.
    – user136036
    Feb 20, 2018 at 22:02
34

QT no longer supports PyQt4, but you can install PyQt5 with pip:

pip install PyQt5
5
  • 1
    Sorry, still not working: "Could not find a version that satisfies the requirement PyQt5 (from versions: )"
    – Igor F.
    Mar 14, 2018 at 12:52
  • you try add option --trusted-host pypi.python.org
    – kien bui
    Mar 20, 2018 at 3:51
  • 3
    This worked for me. It's nice to know that PyQt5 plays nice with pip. Aug 20, 2018 at 15:28
  • When I try this using python 2.7.x - I get "it is not compatible with this Python" messages. ran "pip -v --trusted-host pypi.python.org install PyQt5"
    – Tom
    Nov 8, 2018 at 22:11
  • Qt never supported PyQt4 to begin with - it was Riverbank Computing.
    – oldmud0
    May 26, 2019 at 16:40
17

You can't use pip. You have to download from the Riverbank website and run the installer for your version of python. If there is no install for your version, you will have to install Python for one of the available installers, or build from source (which is rather involved). Other answers and comments have the links.

2
11

If you install PyQt4 on Windows, files wind up here by default:

C:\Python27\Lib\site-packages\PyQt4*.*

but it also leaves a file here:

C:\Python27\Lib\site-packages\sip.pyd

If you copy the both the sip.pyd and PyQt4 folder into your virtualenv things will work fine.

For example:

mkdir c:\code
cd c:\code
virtualenv BACKUP
cd c:\code\BACKUP\scripts
activate

Then with windows explorer copy from C:\Python27\Lib\site-packages the file (sip.pyd) and folder (PyQt4) mentioned above to C:\code\BACKUP\Lib\site-packages\

Then back at CLI:

cd ..                 
(c:\code\BACKUP)
python backup.py

The problem with trying to launch a script which calls PyQt4 from within virtualenv is that the virtualenv does not have PyQt4 installed and it doesn't know how to reference the default installation described above. But follow these steps to copy PyQt4 into your virtualenv and things should work great.

3
  • Hi good answer, I tried to fix up some of the formatting on the answer so that its the same as the standard used on this site. please take a moment to make sure its ok
    – Deepend
    Jul 7, 2015 at 18:41
  • While this is a reasonable answer, I don't think it answers the original question. The original question is asking how to install PyQt4, not how to install it inside a virtual environment. Jul 7, 2015 at 23:57
  • 1
    Thanks for the edits. When I tried to search 'how to install pyqt4 virtualenv windows', I couldn't find anything and found myself reading this post. While I agree it doesn't answer the specific question asked, I figured it was the most logical place to answer the question for the answer for this question since I couldn't find any information and found myself here anyways. Cheers.
    – Dan
    Jul 8, 2015 at 14:53
9

Earlier PyQt .exe installers were available directly from the website download page. Now with the release of PyQt4.12 , installers have been deprecated. You can make the libraries work somehow by compiling them but that would mean going to great lengths of trouble.

Otherwise you can use the previous distributions to solve your purpose. The .exe windows installers can be downloaded from :

https://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.4/

7

It looks like you may have to do a bit of manual installation for PyQt4.

http://pyqt.sourceforge.net/Docs/PyQt4/installation.html

This might help a bit more, it's a bit more in a tutorial/set-by-step format:

http://movingthelamppost.com/blog/html/2013/07/12/installing_pyqt____because_it_s_too_good_for_pip_or_easy_install_.html

1
  • 3
    The OP is trying to install PyQt on Windows. I would guess that compiling everything from scratch on that platform is not a realistic option for them.
    – ekhumoro
    Mar 25, 2014 at 19:51
6

For Windows:

download the appropriate version of the PyQt4 from here:

and install it using pip (example for Python3.6 - 64bit)

 pip install PyQt4‑4.11.4‑cp36‑cp36m‑win_amd64.whl 
5
  • I got this error message: PyQt4‑4.11.4‑cp36‑cp36m‑win_amd64.whl is not a valid wheel filename. Jun 7, 2018 at 18:18
  • You have to execute pip command in the same directory in which "PyQt4‑4.11.4‑cp36‑cp36m‑win_amd64.whl" was downloaded. (the given filename is just an example, you can choose any from the list given in the link given in post)
    – Jay Joshi
    Jun 19, 2018 at 9:07
  • @JayJoshi i got the above error too.i am executing pip command in same directory
    – Arash
    Sep 20, 2019 at 20:27
  • @Arash, Please download the appropriate version from the link provided and install it accordingly. Note: the filename can be changed depending on which version of PyQt4 have you downloaded.
    – Jay Joshi
    Sep 22, 2019 at 6:32
  • @JayJoshi it solved.the problem was that my chosen package was not compatible with python version.for other references cp36 in packages file name means python3.6
    – Arash
    Sep 27, 2019 at 10:29
6

With current latest python 3.6.5

pip3 install PyQt5

works fine

5

Try this for PyQt5:

pip install PyQt5

Use the operating system on this link for PyQt4.

Or download the supported wheel for your platform on this link.

Else use this link for the windows executable installer. Hopefully this helps you to install either PyQt4 or PyQt5.

3

install PyQt5 for Windows 10 and python 3.5+.

pip install PyQt5

4
  • 4
    OP is asking specifically about PyQt4, why should he install PyQt5 instead? Feb 25, 2018 at 21:13
  • 1
    check pierce's answer
    – KEYAN TECH
    Feb 25, 2018 at 21:57
  • My bad, I hadn't this information during the review queue process. Feb 25, 2018 at 21:58
  • 1
    You can always share your knowledge/opinion in comments. In this case there are similar answers with a clearer explanation. Sharing is good but if we all share the same piece of information it's gonna be useless for people. Feb 26, 2018 at 5:53
2

If you have error while installing PyQt4.

Error: PyQt4-4.11.4-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform.

My system type is 64 bit, But to solve this error I have installed PyQt4 of 32 bit windows system, i.e PyQt4-4.11.4-cp27-cp27m-win32.whl - click here to see more versions.

enter image description here

Kindly select appropriate version of PyQt4 according to your installed python version.

1

You can also use this command to install PyQt5.

pip3 install PyQt5
1

I am using PyCharm, and was able to install PyQt5.

PyQt4, as well as PyQt4Enhanced and windows_whl both failed to install, I'm guessing that's because Qt4 is no longer supported.

0

Try using python 3.6,

then install sip

pip install sip then follow the steps mentioned by @Jay https://stackoverflow.com/a/48078369/8352081

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.