Puhh…that is a tricky one! After fiddling a lot it…it seems now so easy…
So I think I have to share that with…everybody who ever is also faced with that strange task
OK…I think you already know that it is not simply possible to make an executable file for a Windows system…with the well know extension: *.exe
But we will make that magic happen … in fact it is not magic its just a combination of the following tools/versions:
- Ubuntu 14.04
- pyinstaller (2.1)
- wine (1.6.2)
- virtual-wine (0.1)
We will make an executable file from our python-project using pyinstaller. We do that in a simulated windows-environment using wine. This, lets call it, ‘simulated windows’ gets an installation of python and pywin32. As it is always a good idea to work clean…we do that in a virtual environment, so our major wine-installation wond’t get touched…isn’t that cool Let’s do it:
Make a test project
Actually, we could make a very simple example like:
print "Hello, this is a test!"
But I a very good tutorial gave some more complex code that worked directly, so we’ll use that:
from Tkinter import *
root = Tk()
root.title('A Tk Application')
Label(text='I am a label').pack(pady=15)
print "Successfully, saved processed!'"
As we can read in the same tutorial, but also here, we can simply make a single execeutable file doing that:
git clone https://github.com/pyinstaller/pyinstaller
python pyinstaller/pyinstaller.py test.py
Check it out…you can already execute it!
Setup a simple ‘virtual windows’
But try that on windows…you will fail! As this is made with Linux it is not executable on windows! I searched a lot for that ‘cross-compiling’ problem and found finally two very good links:
And found out that the guy, who gave the solutions (BTW: Thank you very much!!!) implemented a solution to start wine in a virtual environment. Let’s initialise it:
git clone https://github.com/htgoebel/virtual-wine.git
apt-get install scons
At the end you can choose the type of Windows…I chose Windows7!
Upgrade to a ‘virtual windows-python’
- we can start the new virtual wine-environment (pretty similar to an normal virtualenv), and
- install python and pywin32 (which we have dowloaded from the links above and saved in our folder ‘pyToExe’, in the the meantime
(Helpfull, but I do it differently)
wine msiexec -i python-2.7.8.msi
At this point it is very necessary to use versions that fit exactly to each other!
Make a real .exe*cutable
Now, we have a simple virtual ‘windows-python’ which we can give pyinstall as python-environment:
rm -r build
rm -r dist
wine c:/Python27/python.exe pyinstaller/pyinstaller.py --onefile test.py
Yeah…there is the needed extension, but see test if it works in windows using wine:
What did I say simple isn’t it?!? Go on and try it on a windows…my test where successfull
All still open tabs of my browser in one list, thank you so much!!!
Make following changes to remove warnings :-
- Go to
- Find the
def append(self, tpl):function.
if tpl == "BINARY":to
if tpl in ["BINARY", "DATA"]: