How to install SIP & PyQT on windows 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,
- I've downloaded SIP-4.16.9 and extracted files from the zip folder
- The extracted folder is then copied to C:\Python34\Lib
- Launched a command prompt(cmd) and changed path to C:\Python34\Lib
- Then when I entered
python configure.py
at C:\Python34\Lib and I get the response as below
- 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.
Solution 1:
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.
-
Microsoft Visual Studio 2017 Community Edition (32-bits)
- https://www.visualstudio.com/downloads/
-
Qt 5.9.x
- http://download.qt.io/archive/qt/
When Installing Qt, make sure to select the correct pre-built components you have (for e.g Microsoft Visual Studio 2017)
For Qt 5.8 and earlier :
Downloads
-
Download Python 3.6.x (32-bits) any version will do it :
- https://www.python.org/downloads/
(if you also have python 2.7, make sure to use verions 3 of python)
-
Download sources for sip and PyQt5: Under "Source Packages", download the "Windows Source"
- https://www.riverbankcomputing.com/software/sip/download
- https://www.riverbankcomputing.com/software/pyqt/download5
-
Microsoft Visual Studio 2015 Community Edition (32-bits)
- https://www.microsoft.com/en-us/download/details.aspx?id=48146
-
Qt 5.8.0 for Windows 32-bit (VS 2015, 1.0 GB)
- http://download.qt.io/archive/qt/
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:
1 - SIP
Go to sip-4.19.2 folder and run :
python configure.py
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 ...
"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
[...]
nmake install
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.
Solution 2:
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.)