setting icon using py2exe?

Grant Edwards grante at
Tue Jun 29 21:22:52 CEST 2004

I'm trying in vain to set the icon for the executable generated
by py2exe.  According to various sources there are two answers:

 1) Do it on the command line:

       python py2exe --icon foo.ico

    That generates a usage error:
       error: --icon not recognized

 2) According to
    you can set the icon_resources in the like this:

      from distutils.core import setup
      import py2exe

    That doesn't work either:

      running py2exe
      copying C:\Python23\Lib\site-packages\wx\wxmsw251h_html_vc.dll -> C:\cygwin\home\admin\othertools\dist
      copying C:\Python23\Lib\site-packages\wx\wxbase251h_vc.dll -> C:\cygwin\home\admin\othertools\dist
      copying C:\PYTHON23\w9xpopen.exe -> C:\cygwin\home\admin\othertools\dist
      copying C:\WINDOWS\SYSTEM\python23.dll -> C:\cygwin\home\admin\othertools\dist
      copying C:\Python23\Lib\site-packages\py2exe\run_w.exe -> C:\cygwin\home\admin\othertools\dist\vfcupdate.exe
      Traceback (most recent call last):
        File "", line 5, in ?
        File "C:\PYTHON23\lib\distutils\", line 149, in setup
        File "C:\PYTHON23\lib\distutils\", line 907, in run_commands
        File "C:\PYTHON23\lib\distutils\", line 927, in run_command

        File "C:\Python23\Lib\site-packages\py2exe\", line 197, in run
          self.create_binaries(py_files, extensions, dlls)
        File "C:\Python23\Lib\site-packages\py2exe\", line 395, in create_binaries
          arcname, target.script)
        File "C:\Python23\Lib\site-packages\py2exe\", line 577, in build_executable
          add_icon(unicode(exe_path), unicode(ico_filename), ico_id)
      RuntimeError: MapExistingFile: The handle is invalid.

Has anybody really been able to set the icon for the executable
generated by py2exe?
Grant Edwards                   grante             Yow!  Now I'm concentrating
                                  at               on a specific tank battle
                                 toward the end of World
                                                   War II!

More information about the Python-list mailing list