py2exe automatic upgrades of a program while it is running, is that possible?

Patrick Mullen saluk64007 at
Tue Mar 3 09:20:18 CET 2009

On Mon, Mar 2, 2009 at 6:56 PM, Maxim Khitrov <mkhitrov at> wrote:
> - Show quoted text -
> On Mon, Mar 2, 2009 at 9:18 PM, William Heath <wgheath at> wrote:
>> Hi All,
>> I am using py2exe to create a windows executable.  I am curious if anyone
>> knows a way to automatically upgrade a py2exe windows executable while it is
>> running.  Is that possible?  If so how?  If it isn't possible, what is the
>> next best thing?  Also, if it is not available using py2exe is it available
>> in other languages/solutions your aware of?
>> -Tim

Here's what I did, which works really well.  The main script imports
other python modules which do the real work of the program.  It is
only a few lines long and looks something like this:

import main

There is more stuff there, imports etc to help py2exe find everything,
but that's the basic idea.  Then, to upgrade the program, all I have
to do is replace the modules which are in a subfolder.  (And be
careful to reload them, which has its own considerations).

I do some wonky stuff in my build script to delete my main modules
from since its easier to replace them outside of that, you
could also use the skip-archive option to not use the .zip file at

You really can't replace an exe itself while its running, I would
avoid that as much as possible.  Workarounds to do this are highly
prone to error.

More information about the Python-list mailing list