Getting PyQt5 running on WinPython required a lot of tweaking. WinPython (32 bit) 2.7.10.2 comes with mingw. This is installed in E:\WinPython-32bit-2.7.10.2\python-2.7.10\share\mingwpy. Following the instructions on the PyQt5 download page I first downloaded SIP from this page. I downloaded the zip file for windows. Following these instructions I configured sip for mingw by running
python configure.py --platform win32-g++
The next step then is to run make. However if you start a WinPython Command Prompt you do not have make. I fixed this by copying an old msys installation, from an older (not connected to WinPython) mingw installation, to the mingw folder in the WinPython folder (as noted above). Then by changing the fstab file in msys/1.0/etc to this e:/WinPython-32bit-2.7.10.2/python-2.7.10/share/mingwpy/ /mingw I have a msys system setup for working with the mingw from the WinPython distribution. From a msys shell I can then run make and make install for sip.
Next step is to do the same for PyQt5 download. However, there the configure.py script does not recognize the --platform switch. Use the --spec=win32-g++ switch is also not good enough. The problem is that it somehow still puts "windows" commands in the Makefiles it generates for rename, deleting files folders etc. I could only fix this by changing some code in the configure.py script. In the function run_qmake I added the lines
args.append('-spec')
args.append('win32-g++')
(do this before the "if recursive:" statement). While you are busy editing the configure.py file you can also follow the advice in this forum post to handle any issues with mismatching licenses. Somehow configure.py was detecting a different Qt version. This version was actually located in the site-packages/PyQt4 folder (in WinPython-32bit-2.7.10.2/python-2.7.10). By temporarily renaming this PyQt4 folder you can fix this issue.
After this. If you run
python configure.py --spec=win32-g++
from a msys shell should create the right Makefile (note that this means you have to put WinPython in your system path (environment variables in control panel from advanced system settings in the control panel of windows) because otherwise you have no python in your msys shell. Then you can run make and make install from the msys shell.
Then you are almost done. If at this stage you run a PyQt5 python script it will probably complain that it 'Failed to load platform plugin "windows"'. This was a tricky one to solve. For c++ qt applications it is usually enough to copy the plugins folder to the location of your executable (+ any other needed qt dll's), but what is the location of your executable in this case? I only managed to get it running by adding a new environment variable:
QT_QPA_PLATFORM_PLUGIN_PATH='E:\Qt\5.5\mingw492_32\plugins'
python configure.py --platform win32-g++
The next step then is to run make. However if you start a WinPython Command Prompt you do not have make. I fixed this by copying an old msys installation, from an older (not connected to WinPython) mingw installation, to the mingw folder in the WinPython folder (as noted above). Then by changing the fstab file in msys/1.0/etc to this e:/WinPython-32bit-2.7.10.2/python-2.7.10/share/mingwpy/ /mingw I have a msys system setup for working with the mingw from the WinPython distribution. From a msys shell I can then run make and make install for sip.
Next step is to do the same for PyQt5 download. However, there the configure.py script does not recognize the --platform switch. Use the --spec=win32-g++ switch is also not good enough. The problem is that it somehow still puts "windows" commands in the Makefiles it generates for rename, deleting files folders etc. I could only fix this by changing some code in the configure.py script. In the function run_qmake I added the lines
args.append('-spec')
args.append('win32-g++')
(do this before the "if recursive:" statement). While you are busy editing the configure.py file you can also follow the advice in this forum post to handle any issues with mismatching licenses. Somehow configure.py was detecting a different Qt version. This version was actually located in the site-packages/PyQt4 folder (in WinPython-32bit-2.7.10.2/python-2.7.10). By temporarily renaming this PyQt4 folder you can fix this issue.
After this. If you run
python configure.py --spec=win32-g++
from a msys shell should create the right Makefile (note that this means you have to put WinPython in your system path (environment variables in control panel from advanced system settings in the control panel of windows) because otherwise you have no python in your msys shell. Then you can run make and make install from the msys shell.
Then you are almost done. If at this stage you run a PyQt5 python script it will probably complain that it 'Failed to load platform plugin "windows"'. This was a tricky one to solve. For c++ qt applications it is usually enough to copy the plugins folder to the location of your executable (+ any other needed qt dll's), but what is the location of your executable in this case? I only managed to get it running by adding a new environment variable:
QT_QPA_PLATFORM_PLUGIN_PATH='E:\Qt\5.5\mingw492_32\plugins'
Hi, i have a question: what do you mean with "Then by changing the fstab file in msys/1.0/etc to this e:/WinPython-32bit-2.7.10.2/python-2.7.10/share/mingwpy/ /mingw I have a......" .
ReplyDeleteWhat do you change?
Hi Pablo, sorry for the late reply, I was of the grid for a while. It is not really a change but more an addition I guess. My fstab file looks like this (the lines starting with a hash are comment lines):
ReplyDelete#fstab.sample
#This is a sample file for /etc/fstab.
#Currently /etc/fstab is only read during dll initialization.
#I will eventually watch the directory for changes and reread the file.
#The line format is simple in that you give the Win32 path, followed by one or
#more space or tab delimiter, followed by the mount point. Mount points in
#typical UNIX environments must be a physical name on a drive before it can
#actually be used as a mount point. In this implementation the "must exist"
#requirement isn't enforced, however, it will be an aide to such programs as
#find and readline's tab completion if it does exist.
#You can use a # as the first character on the line as a comment indicator.
#Blank lines are ignored.
#Win32_Path Mount_Point
d:/mingw /mingw
Sorry for WinPython this should be:
ReplyDelete#fstab.sample
#This is a sample file for /etc/fstab.
#Currently /etc/fstab is only read during dll initialization.
#I will eventually watch the directory for changes and reread the file.
#The line format is simple in that you give the Win32 path, followed by one or
#more space or tab delimiter, followed by the mount point. Mount points in
#typical UNIX environments must be a physical name on a drive before it can
#actually be used as a mount point. In this implementation the "must exist"
#requirement isn't enforced, however, it will be an aide to such programs as
#find and readline's tab completion if it does exist.
#You can use a # as the first character on the line as a comment indicator.
#Blank lines are ignored.
#Win32_Path Mount_Point
e:/WinPython-32bit-2.7.10.2/python-2.7.10/share/mingwpy/ /mingw