views:

105

answers:

2

I want to package a Python script so that it can run as a standalone program on Windows XP and later Windows versions. Now to do this I'm pretty sure I'll have to convert it to an .exe file. I know methods exist, what is the easiest/best method?

Now this is where the question gets a little more advanced. I also have some modules the program needs in order to run, can I/how do I package those so that my program can utilize them?

All the modules (if it matters):

import Tkinter
import time
import re
import pickle
import win32api

from win32api import GetSystemMetrics
from PIL import Image, ImageTk
from time import sleep

Next my program also uses PIL in order to display images used in my custom GUI. The thing here is that in order to get the image to run I have to have the complete file path. I have no idea how I'd get this file path on someone else's computer. In short the program requires .png files how do I transfer them so that the program can properly utilize them?

+2  A: 

Take a look at py2exe. It's not perfect, but it will convert your script and all dependencies into an executable. I haven't used it in a while, but I believe it makes a directory of dependencies in the directory of the executable. I suspect that you could change the png to a relative path and put it in that directory.

Good luck!

beitar
A: 

I use Gui2exe and Inno Setup for a good looking windows installer.

Also Upx to compress exe/dll.. this keep the unpacked files after Inno setup small. I dont use Tkinter dont like the look of Tkinter on windows,wxpython is my favorit python gui-toolkit.