Installing pyqt on windows

Install pyqt

PyQt is often not installed by default. The PyQt module can be used to create desktop applications with Python. In this article you’ll learn how to install the PyQt module.

Desktop applications made with PyQt are cross platform, they will work on Microsoft Windows, Apple Mac OS X and Linux computers (including Raspberry Pi).

How to install PyQt5 on Windows?

To install PyQt on Windows there are a few steps you need to take.
First use the installer from the qt-project website, from qt to install PyQt.

Next you want to install a Python version 3.3 or newer. Check the box to add all of the PyQt5 extras. It’s not necessary to compile everything from source, you can install all the required packages with the installer.

On Python >= 3.6, you can also try this command:

It should work without problems.

How to install PyQt5 on Mac OS X?

On Apple Mac OS X installation is a bit simpler. The first step to take is to install the Mac OS X binary. This installs the PyQt GUI library.

But to use it from Python, you also need Python module. This is where the tool brew comes in.
You can use brew to install pyqt (in the terminal):

How to install PyQt5 on Linux?

Python is often installed by default on Linux (in nearly all of the distributions including Ubuntu). But you want to make sure to use Python 3, because of all the features and ease of use. You can verify that you have the newest Python version with the command:

Читайте также:  Windows security icon on start menu

On Ubuntu Linux they sometimes include two versions of python, python3 and python . In that case use Python 3.

Once you have Python ready, the next step is to install PyQt.

This isn’t hard to do if you have some Linux experience. You can install PyQt your software package manager. Which package manager to use depends on which Linux distribution you are using.

On Ubuntu Linux / Debian Linux you can use the command:

How to install PyQt4 on Windows using pip?

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

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?

13 Answers 13

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:

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

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

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.

Читайте также:  Acer uefi bios как установить windows 10

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

but it also leaves a file here:

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

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:

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.

How to install PyQt5 on Windows?

When I try installing the PyQt5 on Windows using the command

I get this error:

I got the pyQt5 from PyQt5 Download.

How can I install PyQt5?

Update:

I installed Qt 5.0.2 for Windows 64-bit (VS 2012, 500 MB) from the Qt Download page and now I have this error:

And when I execute the command python configure.py —verbose :

I added C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin (contains nmake.exe ) to PATH and I got this error:

16 Answers 16

The easiest way to install PyQt is to just use the installer (Link in your answer, step #5). If you install python 3.3, the installer will add all of the PyQt5 extras to that python installation automatically. You won’t need to do any compiling (none of: nmake, nmake install, python configure).

All of the build options are available for if you need a custom install (for instance, using a different version of python, where there isn’t an installer provided by riverbank computing).

Читайте также:  Менеджер запуска windows 10

If you do need to compile your own version of PyQt5, the steps (as you have found) are here, but assume you have python and a compiler installed and in your path. The installed and in your path have been where you have been running into trouble it seems. I’d recommend using the installer version, but you need to install python 3.3 first.

Mainly I use the following command under the cmd

And it works with no problem!

First try this in your Windows cmd window:

If that is successful, it will look something like this:

If that did not work, you might try this link from SourceForge.

How to find the installer that’s right for you?

First, determine what version of Python you have and whether you have 32-bit or 64-bit Python. Next, open one of the directories. I’m on Python 3.5 64-bit so I’m looking for a .exe with those specs. When you open a directory on SourceForge, you will see some directories with ONLY .zip or .tar.gz. That’s not what you’re looking for. A good indication of which directory you should click is given by the «Downloads/Week» column. I’ll open the PyQt-5.6 directory in my case.

Here we notice some .exe files:

I know these are Python 3.5 by Py3.5 in the file name. I am also looking for the 64-bit version so I’ll download PyQt5-5.6-gpl-Py3.5-Qt5.6.0-x64-2.exe . Final answer!

Note: if you try to install a version that’s not compatible with your system, a dialog box will appear immediately after running the .exe. That’s an indication that you’ve chosen the wrong one. I’m not trying to sound like a dbag. I did that several times!

To test a successful install, in your Python interpreter, try to import:

Оцените статью