How to install PyQt4 on Windows using pip?

PythonPython 3.xPyqtPyqt4Pip

Python Problem Overview


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?

Python Solutions


Solution 1 - Python

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.

Solution 2 - Python

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

pip install PyQt5

Solution 3 - Python

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.

Solution 4 - Python

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.

Solution 5 - Python

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/

Solution 6 - Python

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

Solution 7 - Python

With current latest python 3.6.5

pip3 install PyQt5

works fine

Solution 8 - Python

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.

Solution 9 - Python

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 

Solution 10 - Python

install PyQt5 for Windows 10 and python 3.5+.

pip install PyQt5

Solution 11 - Python

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.

Solution 12 - Python

You can also use this command to install PyQt5.

pip3 install PyQt5

Solution 13 - Python

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.

Solution 14 - Python

Try using python 3.6,

then install sip

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAnnaView Question on Stackoverflow
Solution 1 - PythonIvoView Answer on Stackoverflow
Solution 2 - PythonBIMpersonView Answer on Stackoverflow
Solution 3 - PythonOliverView Answer on Stackoverflow
Solution 4 - PythonDanView Answer on Stackoverflow
Solution 5 - PythonxeonView Answer on Stackoverflow
Solution 6 - PythonJames PalawagaView Answer on Stackoverflow
Solution 7 - PythonphysicistView Answer on Stackoverflow
Solution 8 - PythonJaideeView Answer on Stackoverflow
Solution 9 - PythonJay JoshiView Answer on Stackoverflow
Solution 10 - PythonKEYAN TECHView Answer on Stackoverflow
Solution 11 - PythonB-shanView Answer on Stackoverflow
Solution 12 - PythonmthecreatorView Answer on Stackoverflow
Solution 13 - PythonWassingerView Answer on Stackoverflow
Solution 14 - PythonArpit BalView Answer on Stackoverflow