473,545 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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>co mtest --register
Traceback (most recent call last):
File "<string>", line 37, in ?
File "win32com\serve r\register.pyc" , line 468, in UseCommandLine
File "win32com\serve r\register.pyc" , line 405, in RegisterClasses
File "win32com\serve r\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.froze n = 1

class HelloWorld:
_reg_clsctx_ = pythoncom.CLSCT X_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__.Hello World"
_reg_clsid_ = "{B83DD222-7750-413D-A9AD-01B37021B24B}"
_reg_desc_ = "Python Test COM Server"
_reg_progid_ = "Python.TestSer ver"
_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.UseCo mmandLine(Hello World)
else:
# start the server.
from win32com.server import localserver
localserver.mai n()
else:
import win32com.server .register
win32com.server .register.UseCo mmandLine(Hello World)
Jul 18 '05 #1
3 12288
pa*******@stand ardbank.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>co mtest --register
Traceback (most recent call last):
File "<string>", line 37, in ?
File "win32com\serve r\register.pyc" , line 468, in UseCommandLine
File "win32com\serve r\register.pyc" , line 405, in RegisterClasses
File "win32com\serve r\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.froze n:
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.froze n = 1
sys.frozen = 1

class HelloWorld:
_reg_clsctx_ = pythoncom.CLSCT X_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...woul d 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*******@stand ardbank.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>co mtest --register
Traceback (most recent call last):
File "<string>", line 37, in ?
File "win32com\serve r\register.pyc" , line 468, in UseCommandLine
File "win32com\serve r\register.pyc" , line 405, in RegisterClasses
File "win32com\serve r\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.froze n:
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.froze n = 1


sys.frozen = 1

class HelloWorld:
_reg_clsctx_ = pythoncom.CLSCT X_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*******@stand ardbank.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>co mtest --register
Traceback (most recent call last):
File "<string>", line 37, in ?
File "win32com\serve r\register.pyc" , line 468, in UseCommandLine
File "win32com\serve r\register.pyc" , line 405, in RegisterClasses
File "win32com\serve r\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.froze n:
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.froze n = 1


sys.frozen = 1

class HelloWorld:
_reg_clsctx_ = pythoncom.CLSCT X_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
5977
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 well-designed COM like Excel.) When I called my COM module which was derived from IDispatch interface, the pythoncom.connect() issued error like...
5
3958
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 problems. I want to be able to distribute this program using py2exe, but I am having some problems. I am using a simple setup.py like in the...
0
2340
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 code: # start of sample code from win32com.client import *
18
3021
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 a single collections type, I should be proposing a new "namespaces" module instead. Some of my reasons: (1) Namespace is feeling less and less...
0
1225
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 trouble loading the modules, once I have a path to the python source file. This is the error I am getting: mod_info = imp.find_module(module_name,...
17
2022
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 see about hosting it on Sourceforge or something like that. Is this a good forum for exposing modules to the public, or is there somewhere...
0
1190
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 ComboBox or query the input of the user. This COM-module is istantiated(?) via st=win32com.client.Dispatch(..)
1
3441
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 pythoncom from - as a separate module, because I'm using the Python application that comes with my GPS chip, from Telit :-
0
1694
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 complex task, it must ensure that the *right* pywintypes25.dll (or pythoncom25.dll) is loaded, even when it's implicitely loaded.
0
7502
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7692
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7791
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6026
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3491
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.