Deploying Python applications on Windows

Writing applications in Python on a Linux system is almost too easy.  Deploying Python apps on other Linux systems is not hard, because most Linux systems already have Python, with its core libraries and tools, installed.  Most Linux systems also have package managers that make it easy to find and install required components.  But, what happens when your co-workers who use Windows need to use your app?  When you tell them to “go to the command line and…” you’ve pretty much lost them at “command line.” How do you package Python in a way that’s easy for a Windows user to install?
Here is a process that worked for me:

  • Python distutils: You need this to deploy on all types of systems, so it’s best to go ahead and learn it now.  If you’re going to deploy on Windows, make a source distribution in a .zip archive.
  • py2exe is an amazing tool that will bundle your Python application, and all its dependencies, in one place.  Copy the .zip archive created by distutils to a Windows computer.  Install Python and all the required libraries on the Windows PC.  Test the app and make sure it works.  Then, use the py2exe tutorial and the application notes to see how to create a self-contained directory that contains a Windows executable.  You can just zip up this directory and distribute it, and all the user has to do is unzip the archive and double-click the right icon.
  • Optional–create an installer with a tool like NSIS.  I haven’t actually done this, because my app isn’t that complex.  It looks like NSIS will allow you to easily create a professional-looking, wizard-based installer for Windows.  I’d be interested to know how well it works.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.