How to install SIP and PyQT on Windows 7

I am new to Python and really trying to install SIP and PyQt on my Win 7 machine.

This is what I have done so far,

  • I downloaded SIP-4.16.9 and extracted the files from the zip folder
  • Then the extracted folder is copied to C: \ Python34 \ Lib
  • Launched a command prompt (cmd) and changed the path to C: \ Python34 \ Lib
  • Then when I entered python configure.py in C: \ Python34 \ Lib and I get the answer as below

enter image description here

  1. At this point, I'm not sure if it was installed successfully to verify that I was looking for SIP.h in C:\Python34\Include (the answer above is red), but I cannot find any such header file, so I assume That the installation was not successful.

Can someone help me what I am missing here?

Additional system information:

  • Windows 7 64 bit
  • Python 3.4
  • Environment variable (path: C: \ Python34; C: \ Python34 \ Lib; C: \ Python34 \ Lib \ site-packages)

Note Earlier, several questions were asked, but so far none of them have helped, I'm sure that I'm missing something stupid.

Thank you for your time.

+7
source share
3 answers

For the following users who need to create sip (or pyqt) in windows using sources

ALL of these instructions are for 32 bits; they will work even if you have a 64-bit system.

For Qt 5.9.x:

Since Qt 5.9, only one version of Qt is available for Windows, which includes pre-built components for MSVC201x and MinGW.

Instructions follow the same steps as for Qt 5.8

Since Microsoft Visual Studio 2015 Community Edition is not available for download, the following users should use Microsoft Visual Studio 2017 Community Edition with Qt 5.9 and follow the same instructions below.

When installing Qt, make sure that you select the correct pre-built components that you have (for example, Microsoft Visual Studio 2017).

enter image description here

For Qt 5.8 and earlier:

Downloads

(if you also have python 2.7, be sure to use python version 3)

  1. Download sources for sip and PyQt5: in the "Source packages" section, download "Windows source"

  2. Microsoft Visual Studio 2015 Community Edition (32-bit)

  3. Qt 5.8.0 for Windows 32-bit (VS 2015, 1.0 GB)

The Qt download link must match the installed version of Visual Studio (VS) (here VS 2015) and the version of PyQt5 that you need to install

For instance:

  • PyQt5.8.2
  • Qt5.8.0 (link for VS 2015)
  • Microsoft Visual Studio 2015

Compilation

Open a terminal and stay on it.

It is important that you stay on the same terminal ( cmd.exe ) throughout the process, so you do not need to double-provision the environment.

Let me create an environment for compiling PyQt and SIP (to compile PyQt you need to compile sip first)

  • Create a compilation folder on the desktop, for example:
  • Extract the contents of your sip archive in this forlder
  • Extract the contents of your PyQt5 archive in this forlder

Now you need:

 . โ”œโ”€โ”€ compilation | โ”œโ”€โ”€ sip-4.19.2/ | โ””โ”€โ”€ PyQt5_gpl-5.8.2/ 

Make sure you are using Python 3.x:

enter image description here

1 - SIP

Go to the sip-4.19.2 folder and run:

python configure.py

enter image description here

At this point you did not install sip, you only configured it (basically its installation directory, etc.)

VERY IMPORTANT STEP: specify the environment variables running in the terminal:

Keep double quotes, windows don't like spaces ...

enter image description here

 "C:\Qt\Qt5.8.0\5.8\msvc2015\bin\qtenv2.bat" 

After running this command, it will automatically change your current directory, remain on the terminal and go to the sip-4.19.2 directory and start:

 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" 

In windows, "make" is replaced by "nmake"!

Then (always in the same terminal) you run:

 nmake 

enter image description here

[...]

enter image description here

 nmake install 

enter image description here

This will create the sip.exe file in your Python directory, for me it is C:\Python36 , it may be in another place, depending on where you installed Python.

2 - PyQt5

The steps are almost the same as sip, but it will take longer.

Go to the PyQt5_gpl-5.8.2 folder and run:

python configure.py --disable QtNfc --confirm-license

Please note that this command disables QtNfs due to a compilation problem that I could not solve .. and automatically accepts the license.

Then run (compilation will take some time):

 nmake nmake install 

Hope this helps.

+12
source

There is an ONE SHOT solution for all your installation problems in Windows. Go to this site. http://www.lfd.uci.edu/~gohlke/pythonlibs/ . Go to the desired library and download the .whl file for your version of python and your computer (32 or 64 bit). Then run pip install YourWhlFileName.whl and you pip install YourWhlFileName.whl done! (CAUTION: MAKE SURE TO DO NOT CHANGE WHL FILE NAME OR THIS DOES NOT WORK.)

+2
source

This is for anyone who wants to create PyQt4 with the latest Qt4 and Python 3.4.x.

Download Visual Studio 2010 from here: http://download.cnet.com/Microsoft-Visual-Studio-2010-Ultimate/3000-2383_4-75450998.html

then install it.

Download the SIP source code (in my case version 4.19.5) from here: https://www.riverbankcomputing.com/software/sip/download

Download the source code of PyQt4 (in my case version 4.12.1): https://www.riverbankcomputing.com/software/pyqt/download

Extract the SIP and PyQt.zip archive to \ Users \ your_username \ Desktop \ compilation \

Download the latest Qt 4.x installer (vs2010): http://download.qt.io/archive/qt/

Install Qt (in my case qt-opensource-windows-x86-vs2010-4.8.6.exe).

Open a command prompt (use it for the entire process) and run the following commands:

 cd \Users\<your_username>\Desktop\compilation\sip-4.19.5 python configure.py "C:\Qt\4.8.6\bin\qtvars.bat" 

In the output, pay attention to the value of QMAKESPEC, in my case win32-msvc2010, and then use it later in the -spec option for the PyQt4 configure-ng script.

If the current directory has been changed, run again:

 cd \Users\<your_username>\Desktop\compilation\sip-4.19.5 

Now, if you are using the 64-bit version of Python, do:

 "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" 

otherwise, if you are using the 32-bit version of Python:

 "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat" nmake nmake install cd \Users\<your_username>\Desktop\compilation\PyQt4_gpl_win-4.12.1 

Now use the previous QMAKESPEC value in the -spec option:

 python configure-ng.py --spec win32-msvc2010 nmake nmake install 

What all; -)

NOTE : in some cases, to avoid this error

 ImportError: DLL load failed: The specified procedure could not be found. 

need to copy the dll files from

 C:\Qt\4.8.6\bin 

to

 C:\Python34\Lib\site-packages\PyQt4 
0
source

All Articles