top button
Flag Notify
Connect to us
    Facebook Login
    Site Registration Why to Join

    Get Free Article Updates

Facebook Login
Site Registration
Print Preview

Distributing python applications as a zip file

+1 vote

A little known feature of Python: you can wrap your Python application in a zip file and distribute it as a single file. The trick to make it runnable is to put your main function inside a file called
inside the zip file.


$ cat 
print("Hello World!!!")

$ zip appl 
adding: (stored 0%)

$ rm 
$ python 
Hello World!!!

On Linux, you can even hack the zip file to include a shebang line!

$ cat appl
!/usr/bin/env python
This is a Python application stored in a ZIP archive.
$ cat >> appl
$ chmod u+x appl
$ ./appl
Hello World!!!

It's not quite self-contained, as you still need to have Python installed, but otherwise it's a good way to distribute a Python application as a single file that users can just copy and run.

posted Jul 23, 2014 by anonymous

  Promote This Article
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

Contact Us
+91 9880187415
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.