Hello all, I’ve continued my efforts to create a COM server with Python and have found success by implementing one without the overhead of a GUI event loop (my Tkinter app didn’t work as a COM server). I’ve created the server and confirmed that it works when run from Python, but I am not able to deploy it via py2exe. I get this familiar error:
Traceback (most recent call last): File "boot_com_servers.py", line 4, in <module> ImportError: No module named win32api I’ve reviewed the list archives and elsewhere to determine what might be the issue, and I’ve added all the appropriate statements that I can think of to the setup script (importing various pywin modules, explicitly setting win32api as a package to include, etc.). I’m using the latest ActivePython 2.7 with fresh installations of py2exe and pythonwin on Windows 7. I’m a bit baffled here, so any advice is appreciated. My setup.py script is below. Thanks! # -*- coding: cp1252 -*- # This is the distutils script for creating a Python-based com (exe or dll) # server using win32com. This script should be run like this: # # % python setup.py py2exe # # After you run this (from this directory) you will find two directories here: # "build" and "dist". The .dll or .exe in dist is what you are looking for. ############################################################################## import glob import os import sys import shutil import pywintypes import pythoncom import win32api try: # py2exe 0.6.4 introduced a replacement modulefinder. # This means we have to add package paths there, not to the built-in # one. If this new modulefinder gets integrated into Python, then # we might be able to revert this some day. # if this doesn't work, try import modulefinder try: import py2exe.mf as modulefinder except ImportError: import modulefinder import win32com for p in win32com.__path__[1:]: modulefinder.AddPackagePath("win32com", p) for extra in ["win32com.shell"]: #,"win32com.mapi" __import__(extra) m = sys.modules[extra] for p in m.__path__[1:]: modulefinder.AddPackagePath(extra, p) except ImportError: # no build path setup, no worries. pass from distutils.core import setup import py2exe import sys class Target: def __init__(self, **kw): self.__dict__.update(kw) self.version = "3.2.0" self.company_name = "WordTech Communications LLC" self.copyright = "(c) 2011 WordTech Communications LLC" self.name = "QuickWho" quickwho_com_target = Target( description = "QuickWho COM server", # use module name for win32com exe/dll server modules = ["quickwho_com"], create_exe = True, create_dll = False ) setup( name="QuickWho", # the following two parameters embed support files within exe/dll file options={"py2exe": { "bundle_files": 3, 'packages' : ['win32api'] } }, zipfile=None, version="3.2.0", description="QuickWho COM Server", com_server=[quickwho_com_target], )
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32