472,989 Members | 3,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,989 software developers and data experts.

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

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 )
Jul 18 '05 #1
3 12160
pa*******@standardbank.com (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
Jul 18 '05 #2
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 <th*****@python.net> wrote in message news:<sm**********@python.net>...
pa*******@standardbank.com (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

Jul 18 '05 #3
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 <th*****@python.net> wrote in message news:<sm**********@python.net>...
pa*******@standardbank.com (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

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John J. Lee | last post by:
Dear, I have problems when I get the IDispatch with pythoncom.connect(). When I called the 'Excel.Application' with it, it worked. (At least I can see the pythoncom.connect() is working for the...
5
by: Brian Hlubocky | last post by:
I'm have a fairly simple (in terms of COM) python program that pulls info from an Access database and creates Outlook contacts from that information. It uses wxPython for gui and works without...
0
by: gloom | last post by:
Hey, I'm programming something with NeroSDK COM module, and I bumped into a problem: why doesn't python releases and uninitializes COM objects that are no longer referenced? Here is a sample...
18
by: Steven Bethard | last post by:
In the "empty classes as c structs?" thread, we've been talking in some detail about my proposed "generic objects" PEP. Based on a number of suggestions, I'm thinking more and more that instead of...
0
by: Calvin Spealman | last post by:
I've been working on a small test runner script, to accumulate my test scripts (all python files in the 'test' sub-directories of my source tree). Things were going well, but I'm still having...
17
by: Jacob Page | last post by:
I have created what I think may be a useful Python module, but I'd like to share it with the Python community to get feedback, i.e. if it's Pythonic. If it's considered useful by Pythonistas, I'll...
0
by: ChristianHahn | last post by:
Hi, I inherited a piece of code, that doesn't work anymore. It's a COM-object. One interface method opens a modal dialog ( OpenDialog() ), with the other methods one can set the values for a...
1
by: John Walsh | last post by:
Hi, I'd like to write a python script to control Google Earth, and I've read that Google Earth provides a COM api, and that Python has a COM module 'pythoncom'. Anyone know where to get...
0
by: Gabriel Genellina | last post by:
En Wed, 27 Aug 2008 21:17:22 -0300, Vistro <vistro@vistro.netescribi�: Reinstalling the pywin32 package should fix that, I presume. In fact that __import_whatever function does a rather...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.