How to make an executable from a Python script?
Introduction
This is a simple web tutorial whose purpose is to add to the web resources available on the Internet. Actually, there are quite a few applications able to create executable programs from python scripts. Even though python scripts are quite small, the resulting executable is often quite big, and has to ship along with many DLL files. I'll write a simple script with python, then generate a win32 executable file.
Write (or get) the script
I've been fiddling around with socket programming, so I'm inclined to write a MSN messages sniffing program.
Here's what you'll need to get through this part:
Oh... the wonders of spying into someone else's affairs. Never gets old, huh?
Creating the executable
So, the script worked nicely, but you can't run it on a machine that doesn't have python installed. Bummer.
Here's the ingredients you'll need to get a fully runable executable out of your .py script:
You'll get lots of printed output, and (hopefully) a subdir called "dist" where you'll find your brand new executable!
Afterword
Most of the MSN sniffers out there are expensive shareware, and I thought it'd be fun to write my own. Also, lots of pythonistas out there seem to be unaware of how easy and simple it is to transform small scripts into fully blown (and bloated) windows executables.
If you're simply interested in downloading pymsnsniffer executables, here's the link.
Feedback is most welcome, and have fun!
This is a simple web tutorial whose purpose is to add to the web resources available on the Internet. Actually, there are quite a few applications able to create executable programs from python scripts. Even though python scripts are quite small, the resulting executable is often quite big, and has to ship along with many DLL files. I'll write a simple script with python, then generate a win32 executable file.
Write (or get) the script
I've been fiddling around with socket programming, so I'm inclined to write a MSN messages sniffing program.
Here's what you'll need to get through this part:
- Python installed on your computer (I used the 2.6 version). You can get it at www.python.org.
- Learn python and write your own script... Just kidding! You can use this little script I've written myself pymsnsniffer.py.
- Test the script.
And a file named MSN_(date).txt should've been created on the same directory where you ran the script from:
Oh... the wonders of spying into someone else's affairs. Never gets old, huh?
Creating the executable
So, the script worked nicely, but you can't run it on a machine that doesn't have python installed. Bummer.
Here's the ingredients you'll need to get a fully runable executable out of your .py script:
- Download and install cx_Freeze. The windows installer is readily available.
- Run the the cxfreeze on your script.
You'll get lots of printed output, and (hopefully) a subdir called "dist" where you'll find your brand new executable!
Afterword
Most of the MSN sniffers out there are expensive shareware, and I thought it'd be fun to write my own. Also, lots of pythonistas out there seem to be unaware of how easy and simple it is to transform small scripts into fully blown (and bloated) windows executables.
If you're simply interested in downloading pymsnsniffer executables, here's the link.
Feedback is most welcome, and have fun!
Comments
Post a Comment