Error using py2exe...

Mario T. mtbros at libero.it
Fri Oct 5 16:24:30 EDT 2001


Hi,
Thomas Heller posted this example of the use of his py2exe to build a local
COM server:

------------------ EXAMPLE -----------------------

------------------testCOMserver.py-----------------------
import sys
import pythoncom

if hasattr(sys, 'importers'):
    # we are running as py2exe-packed executable
    pythoncom.frozen = 1

class HelloWorld:
    _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
    if hasattr(sys, 'importers'):
        # In the py2exe-packed version, specify the module.class
        # to use. In the python script version, python is able
        # to figure it out itself.
        _reg_class_spec_ = "__main__.HelloWorld"
    _reg_clsid_ = "{B83DD222-7750-413D-A9AD-01B37021B24B}"
    _reg_desc_ = "Python Test COM Server"
    _reg_progid_ = "Python.TestServer"
    _public_methods_ = ['Hello']
    _public_attrs_ = ['softspace', 'noCalls']
    _readonly_attrs_ = ['noCalls']
    def __init__(self):
        self.softspace = 1
        self.noCalls = 0
    # __init__()

    def Hello(self, who):
        self.noCalls = self.noCalls + 1
        # insert "softspace" number of spaces
        return "Hello" + " " * self.softspace + str(who)

if __name__ == '__main__':
    if hasattr(sys, 'importers'):
        # running as packed executable.
        if '--register' in sys.argv[1:]            or '--unregister' in
sys.argv[1:]:
            # --register and --unregister work as usual
            import win32com.server.register
            win32com.server.register.UseCommandLine(HelloWorld)
        else:
            # start the server.
            from win32com.server import localserver
            localserver.main()
    else:
        import win32com.server.register
        win32com.server.register.UseCommandLine(HelloWorld)
---------------------------------------------------------

This is the setup script you can use to build an executable
with py2exe:

----------------------setup.py---------------------------
from distutils.core import setup
import py2exe

setup(name='testCOMserver',
      scripts=['testCOMserver.py'])
---------------------------------------------------------

------------------END  EXAMPLE -----------------------

But typing on the command prompt
> python setup.py py2exe
I'm running into troubles:

warning: install: modules installed to
'build\bdist.win32\winexe\lib\Dev\Lang\Python21\', which is not in Python's
module search path (sys.path) -- you'll have to change the search path
yourself
Traceback (most recent call last):
  File "setup.py", line 5, in ?
    scripts=['testCOMserver.py'])
  File "D:\Dev\Lang\Python21\lib\distutils\core.py", line 138, in setup
    dist.run_commands()
  File "D:\Dev\Lang\Python21\lib\distutils\dist.py", line 899, in
run_commands
    self.run_command(cmd)
  File "D:\Dev\Lang\Python21\lib\distutils\dist.py", line 919, in
run_command
    cmd_obj.run()
  File "D:\Dev\Lang\Python21\py2exe\py2exe.py", line 397, in run
    dlls, unfriendly_dlls = self.find_dependend_dlls(use_runw, dlls)
  File "D:\Dev\Lang\Python21\py2exe\py2exe.py", line 510, in
find_dependend_dlls
    alldlls, warnings = bin_depends(loadpath, images)
  File "D:\Dev\Lang\Python21\py2exe\py2exe.py", line 703, in bin_depends
    for result in py2exe_util.depends(image, loadpath).items():
py2exe_util.bind_error: D:\Dev\Lang\Python21\py2exe\run.exe

Well,  I have never used py2exe before, so do you have any pointer on what
this mean ?
I'm running python 2.1.1 from ActiveState
TIA, Mario







More information about the Python-list mailing list