How to install SIP & PyQT on windows 7
Asked Answered
N

3

7

I'm a newbie to Python environment & really struggling to install SIP & PyQt on my Win 7 machine.

This is what I've done so far,

  1. I've downloaded SIP-4.16.9 and extracted files from the zip folder
  2. The extracted folder is then copied to C:\Python34\Lib
  3. Launched a command prompt(cmd) and changed path to C:\Python34\Lib
  4. Then when I entered python configure.py at C:\Python34\Lib and I get the response as below

enter image description here

  1. At this stage I'm not sure whether it's been installed successfully, to verify I looked for SIP.h at C:\Python34\Include(according to above response - in red), but I cant find any such header file, so I assume the installation hasn't been successful.

Could any one help me, what am I missing here?

Additional System Info:

  • Windows 7 64 Bit
  • Python 3.4
  • Environment Variable (Path : C:\Python34;C:\Python34\Lib;C:\Python34\Lib\site-packages)

Note: There are several questions posted before, but none of them helped so far, I'm sure I must be missing something silly.

Thanks for your time.

Nissen answered 17/8, 2015 at 15:19 Comment(6)
Personally I gave up on maintaining my own python environment a while ago and took the easy way out and run Anaconda now. It's a python distribution that has QT, NumPy, SciPy, IPython, PyTables, pandas, Matplotlib, scikit-learn, and other packages already configured and good to go. Check it out at continuum.io/downloads#py34Deceleron
From the documentation it sounds like the next step after configuring is to build it. Suggest you try that and then ask a question if there's a problem.Ergotism
@ Check Thanks for the link, I had this while ago & removed when some one suggested me to use PyCharm.Nissen
@martineau, make didn't work. I get an error message as "make is not recognised as an internal or external command", thanks for the suggestion though.Nissen
So now you've discovered an even more fundamental problem — which is that you don't have the C/C++ compiler and make utility needed to build the extension. You may also need to download the source code for the version of Python you're using.Ergotism
I'm sure I have got C/C++ compiler installed along with VS 2012 Professional version, by the way what does this make do? is it a DOS related command?Nissen
T
18

For next users who need to build sip (or pyqt) in windows using sources

ALL these instructions are for 32-bits, it will work even if you have a 64-bit system.

For Qt 5.9.x :

Since Qt 5.9, there is only one version of Qt downloadable for Windows that includes the pre-built components for MSVC201x and MinGW.

The instructions follow the same steps as for Qt 5.8

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

  1. Microsoft Visual Studio 2017 Community Edition (32-bits)

  2. Qt 5.9.x

When Installing Qt, make sure to select the correct pre-built components you have (for e.g Microsoft Visual Studio 2017)

enter image description here

For Qt 5.8 and earlier :

Downloads

  1. Download Python 3.6.x (32-bits) any version will do it :

(if you also have python 2.7, make sure to use verions 3 of python)

  1. Download sources for sip and PyQt5: Under "Source Packages", download the "Windows Source"

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

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

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

For example:

  • 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 you stay on the same terminal (cmd.exe) during the whole process so you don't have to source your environment twice.

Let's create an environment to compile PyQt and SIP (in order to compile PyQt, you need first to compile sip)

  • Create a folder "compilation" in your Desktop for example:
  • Extract the content of your sip archive in this forlder
  • Extract the content of your PyQt5 archive in this forlder

You should have now :

.
├── 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 sip-4.19.2 folder and run :

python configure.py

enter image description here

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

VERY IMPORTANT STEP: source your environment variables by running in the terminal :

Keep the double quotes, windows does not like spaces ...

enter image description here

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

After running this command, it automatically change your current directory, stay on the terminal and re-go to your sip-4.19.2 directory and run:

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

In windows, "make" is substituted 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 a sip.exe in your Python dir, for me it is C:\Python36, it may elsewhere, depending on where you installed Python.

2 - PyQt5

The steps are almost the same as sip but it will take more time.

Go to PyQt5_gpl-5.8.2 folder and run :

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

Note that this command disable QtNfs because of a compilation problem I could not resolve.. and automatically accepts the license.

Then, run (the compilation will take a while) :

nmake
nmake install

Hope this helps.

Til answered 24/11, 2016 at 6:26 Comment(8)
This is very helpful. At the nmake step, in ~\VC\bin, I used: nmake c:\python27\path_to_sip_makefile\Makefile but get an error message: `cd sipgen NMAKE : fatal error U1077: 'cd' : return code 0x1 Stop.'Bronchitis
Are you running nmake from your sip dir (where you runned python configure.py) ? because I don't remember having specified a Makefile with nmake. If you still have issues we can have a chat chat.stackoverflow.com/rooms/135711/build-sip-in-windowsTil
I'm running nmake from its directory (in ~VC\bin). I know it's finding the Makefile because the first line in the Makefile is cd sipgen Do I need to have some kind of special compiler installed?Bronchitis
Thank you for the stright forward post! Makes a lot of sense. I am hitting a issues with version mismatches during the nmake. The error message I am getting is: fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86' How should I go about debugging thisFact
@jspada, you will have to install all elements either 32bits or 64bits, you cannot mix (e.g MVS2015 64bits and Qt 32bits)Til
Thanks! I did not realize I had python 64 bit installed, not 32, which was tripping me up.Fact
Ok, based on the last few comments, I am using msvc2015_64 and also using vcvars64.bat and I am able to compile until the last line where I am given the error: "'mt' is not recognized as an internal or external command,operable program or batch file." I am assuming this is not in my path and I have to find it, is this correct?Metaphysical
Found the mt.exe in Windows SDK, v7.1a, x64.Metaphysical
C
3

There's a ONE SHOT solution to all your installation problems on Windows. Go to this website. http://www.lfd.uci.edu/~gohlke/pythonlibs/. Navigate to the library you want and download the .whl file for your python version and your computer (32 or 64 bit.) Then run pip install YourWhlFileName.whl, and you're done! (CAUTION: MAKE SURE NOT TO CHANGE THE NAME OF THE WHL FILE OR IT WON'T WORK.)

Conditioned answered 17/8, 2015 at 16:3 Comment(2)
Thanks for the link, but before I try this I really want to figure out the issue and find a fix.Nissen
It's a great resource and has saved my ass multiple times, but it doesn't host any wheels for sip whatsoever...Kirima
A
0

This is for all that want to build PyQt4 with 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 SIP source code (in my case version 4.19.5) from here: https://www.riverbankcomputing.com/software/sip/download

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

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

Download latest Qt 4.x (vs2010 version) installer from here: 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 this one for all the process) and execute these 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 take note of QMAKESPEC value, in my case win32-msvc2010, then use it later on --spec option for PyQt4 configure-ng script.

If the current directory has been changed, execute again:

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

Now, if you use 64-bit version of Python execute:

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

otherwise, if you use 32-bit version of Python execute:

"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 previous QMAKESPEC value in --spec option:

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

That's all ;-)

NOTE: in some cases, in order to avoid this error

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

it is necessary to copy .dll files from

C:\Qt\4.8.6\bin

to

C:\Python34\Lib\site-packages\PyQt4
Africanist answered 6/11, 2017 at 19:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.