Index: setuptools/command/bdist_egg.py =================================================================== --- setuptools/command/bdist_egg.py (revision 66050) +++ setuptools/command/bdist_egg.py (working copy) @@ -29,7 +29,9 @@ " import sys, pkg_resources, imp", " __file__ = pkg_resources.resource_filename(__name__,%r)" % resource, - " del __bootstrap__, __loader__", + " del __bootstrap__", + " if '__loader__' in globals():", + " del __loader__", " imp.load_dynamic(__name__,__file__)", "__bootstrap__()", "" # terminal \n