pythoncom - 'module' object has no attribute 'frozen'

Discussion in 'Python' started by Paul, Oct 17, 2003.

  1. Paul

    Paul Guest

    Hi

    I'm trying to build a standalone COM exe server using Python 2.2 +
    Mark Hammond's windows extensions + Py2Exe. I've built the example
    linked on the Py2Exe homepage and get this error when running the exe:

    I:\Program Files\Python22\dist\comtest>comtest --register
    Traceback (most recent call last):
    File "<string>", line 37, in ?
    File "win32com\server\register.pyc", line 468, in UseCommandLine
    File "win32com\server\register.pyc", line 405, in RegisterClasses
    File "win32com\server\register.pyc", line 188, in RegisterServer
    AttributeError: 'module' object has no attribute 'frozen'

    Does anyone know what I'm doing wrong? thanks. btw, I have to use
    Python 2.2.

    Source code is:


    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)
    Paul, Oct 17, 2003
    #1
    1. Advertising

  2. (Paul) writes:

    > Hi
    >
    > I'm trying to build a standalone COM exe server using Python 2.2 +
    > Mark Hammond's windows extensions + Py2Exe. I've built the example
    > linked on the Py2Exe homepage and get this error when running the exe:
    >
    > I:\Program Files\Python22\dist\comtest>comtest --register
    > Traceback (most recent call last):
    > File "<string>", line 37, in ?
    > File "win32com\server\register.pyc", line 468, in UseCommandLine
    > File "win32com\server\register.pyc", line 405, in RegisterClasses
    > File "win32com\server\register.pyc", line 188, in RegisterServer
    > AttributeError: 'module' object has no attribute 'frozen'
    >
    > Does anyone know what I'm doing wrong? thanks. btw, I have to use
    > Python 2.2.


    Mark Hammond changed his code to support McMillan installer.
    Looking at line 188 in win32com\server\register.py explains what happens:

    187 if pythoncom.frozen:
    188 assert sys.frozen, "pythoncom is frozen, but sys.frozen is not set - don't know the context!"
    189 if sys.frozen == "dll":

    You need to make sure that sys.frozen is also set, but better not to
    'dll'. I didn't try it, but the next step for you would be to change
    your code in the way mentioned below:

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


    sys.frozen = 1

    >
    > class HelloWorld:
    > _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER

    [...]

    The good news is that Mark and I are currently working on a brand new
    version of py2exe which will support 2.3 only, but which is much better
    integrated with the win32all stuff. In this version, you don't have to
    do anything special in your com server code, although you have to change
    your setup script a little bit.

    Thomas
    Thomas Heller, Oct 17, 2003
    #2
    1. Advertising

  3. Paul

    Paul Guest

    Thanks Thomas - adding the sys.frozen = 1 line seemed to do the trick.

    I'm a bit of a beginner...would you mind explaining to me what the
    'frozen' bit means?

    Thanks
    Paul

    Thomas Heller <> wrote in message news:<>...
    > (Paul) writes:
    >
    > > Hi
    > >
    > > I'm trying to build a standalone COM exe server using Python 2.2 +
    > > Mark Hammond's windows extensions + Py2Exe. I've built the example
    > > linked on the Py2Exe homepage and get this error when running the exe:
    > >
    > > I:\Program Files\Python22\dist\comtest>comtest --register
    > > Traceback (most recent call last):
    > > File "<string>", line 37, in ?
    > > File "win32com\server\register.pyc", line 468, in UseCommandLine
    > > File "win32com\server\register.pyc", line 405, in RegisterClasses
    > > File "win32com\server\register.pyc", line 188, in RegisterServer
    > > AttributeError: 'module' object has no attribute 'frozen'
    > >
    > > Does anyone know what I'm doing wrong? thanks. btw, I have to use
    > > Python 2.2.

    >
    > Mark Hammond changed his code to support McMillan installer.
    > Looking at line 188 in win32com\server\register.py explains what happens:
    >
    > 187 if pythoncom.frozen:
    > 188 assert sys.frozen, "pythoncom is frozen, but sys.frozen is not set - don't know the context!"
    > 189 if sys.frozen == "dll":
    >
    > You need to make sure that sys.frozen is also set, but better not to
    > 'dll'. I didn't try it, but the next step for you would be to change
    > your code in the way mentioned below:
    >
    > > import sys
    > > import pythoncom
    > >
    > > if hasattr(sys, 'importers'):
    > > # we are running as py2exe-packed executable
    > > pythoncom.frozen = 1

    >
    > sys.frozen = 1
    >
    > >
    > > class HelloWorld:
    > > _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER

    > [...]
    >
    > The good news is that Mark and I are currently working on a brand new
    > version of py2exe which will support 2.3 only, but which is much better
    > integrated with the win32all stuff. In this version, you don't have to
    > do anything special in your com server code, although you have to change
    > your setup script a little bit.
    >
    > Thomas
    Paul, Oct 18, 2003
    #3
  4. Paul

    Paul Guest

    Thanks Thomas - adding the sys.frozen = 1 line seemed to do the trick.

    I'm a beginner here - would you mind explaining to me what the
    'frozen' attribute means?

    Thanks
    Paul

    Thomas Heller <> wrote in message news:<>...
    > (Paul) writes:
    >
    > > Hi
    > >
    > > I'm trying to build a standalone COM exe server using Python 2.2 +
    > > Mark Hammond's windows extensions + Py2Exe. I've built the example
    > > linked on the Py2Exe homepage and get this error when running the exe:
    > >
    > > I:\Program Files\Python22\dist\comtest>comtest --register
    > > Traceback (most recent call last):
    > > File "<string>", line 37, in ?
    > > File "win32com\server\register.pyc", line 468, in UseCommandLine
    > > File "win32com\server\register.pyc", line 405, in RegisterClasses
    > > File "win32com\server\register.pyc", line 188, in RegisterServer
    > > AttributeError: 'module' object has no attribute 'frozen'
    > >
    > > Does anyone know what I'm doing wrong? thanks. btw, I have to use
    > > Python 2.2.

    >
    > Mark Hammond changed his code to support McMillan installer.
    > Looking at line 188 in win32com\server\register.py explains what happens:
    >
    > 187 if pythoncom.frozen:
    > 188 assert sys.frozen, "pythoncom is frozen, but sys.frozen is not set - don't know the context!"
    > 189 if sys.frozen == "dll":
    >
    > You need to make sure that sys.frozen is also set, but better not to
    > 'dll'. I didn't try it, but the next step for you would be to change
    > your code in the way mentioned below:
    >
    > > import sys
    > > import pythoncom
    > >
    > > if hasattr(sys, 'importers'):
    > > # we are running as py2exe-packed executable
    > > pythoncom.frozen = 1

    >
    > sys.frozen = 1
    >
    > >
    > > class HelloWorld:
    > > _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER

    > [...]
    >
    > The good news is that Mark and I are currently working on a brand new
    > version of py2exe which will support 2.3 only, but which is much better
    > integrated with the win32all stuff. In this version, you don't have to
    > do anything special in your com server code, although you have to change
    > your setup script a little bit.
    >
    > Thomas
    Paul, Oct 18, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?ISO-8859-1?Q?Thomas_N=FCcker?=

    sys.argv[0] - 'module' object has no attribute 'argv'

    =?ISO-8859-1?Q?Thomas_N=FCcker?=, Jun 30, 2003, in forum: Python
    Replies:
    0
    Views:
    898
    =?ISO-8859-1?Q?Thomas_N=FCcker?=
    Jun 30, 2003
  2. johnny
    Replies:
    5
    Views:
    719
    johnny
    Dec 10, 2006
  3. Gabriel Genellina

    Re: pythoncom module

    Gabriel Genellina, Jan 3, 2007, in forum: Python
    Replies:
    0
    Views:
    481
    Gabriel Genellina
    Jan 3, 2007
  4. est
    Replies:
    1
    Views:
    549
  5. LC Geldenhuys
    Replies:
    5
    Views:
    254
    Robert Klemme
    Feb 18, 2004
Loading...

Share This Page