473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

COM server and EXE

Hi All,

I have a Python COM server. I need to deploy it on various sytems.
When I run the COM server from
python its showing an output " Registered : sample.lib"

If I try to use the COM obj from a VB client like:

obj = CreateObject("sample.lib")

Its working fine without any errors

Now I am trying to convert this COM server to an exe through py2exe
and after I run the exe, I am
getting the same output " Registered : sample.lib"

But If I try to use the COM obj from a VB client like

obj = CreateObject("sample.lib")

A console pops up saying " Registered : sample.lib" and VB application
hangs there.
Its throwing a VB error that "ActiveX object cannot be
created......etc etc"

Any suggestions please.......

Regards,
Tejovathi
Jan 8 '08 #1
2 2252
On Jan 8, 3:33*pm, Teja <tejovath...@gmail.comwrote:
Hi All,

I have a Python COM server. I need to deploy it on various sytems.
When I run the COM server from
python its showing an output " Registered : sample.lib"

If I try to use the COM obj from a VB client like:

obj = CreateObject("sample.lib")

Its working fine without any errors

Now I am trying to convert this COM server to an exe through py2exe
and after I run the exe, I am
getting the same output " Registered : sample.lib"

But If I try to use the COM obj from a VB client like

obj = CreateObject("sample.lib")

A console pops up saying " Registered : sample.lib" and VB application
hangs there.
Its throwing a VB error that "ActiveX object cannot be
created......etc etc"

Any suggestions please.......

Regards,
Tejovathi
Here is my sample COM server and py2exe setup file

testCOM.py

import win32com.client
import os.path
import shutil
from win32api import Sleep
import string
import os
import sys
import pythoncom

class FirstEx:

_reg_clsid_ = "{A6DE9DF8-5EBF-48E6-889E-C71CB84CFF2C}"
pythoncom.frozen = 1
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__.FirstEx"
_reg_desc_ = "My first COM server"
_reg_progid_ = "SAMPLE.Lib"
_public_methods_ = ['init', 'Version']
_public_attrs_ = ['softspace', 'noCalls']
_readonly_attrs_ = ['noCalls']
_reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER

def __init__(self):
self.softspace = 1
self.noCalls = 0
def Version(self):
self.noCalls = self.noCalls + 1

# insert "softspace" number of spaces
return "Version: 0.0.1"
if __name__=='__main__':
import sys
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(FirstEx)
else:
# start the server.
from win32com.server import localserver
localserver.main()
else:
import win32com.server.register
win32com.server.register.UseCommandLine(FirstEx)

Here is my setup file:

#Start here
from distutils.core import setup
import py2exe

setup(options = {"py2exe": {"compressed": 1,
"optimize": 2,
"ascii": 1,
"bundle_files": 1}},
zipfile = None,
com_server = ["win32com.servers.interp"],
console = ["testCOM.py"])
#End here
Here is my VB code:

Sub subRoutine()
Dim connection As Object
Dim returnvalue1 As String
Dim returnvalue2 As String
Dim flag3 As Boolean

Set connection = CreateObject("SAMPLE.Lib")
returnvalue1 = connection.Version()
MsgBox (returnvalue1)
End Sub
The non exe version of the COM server ie. directlly running the
testCOM.py registers the library properly and

in the VB application, the message box displays the version as 0.0.1.

But, after I create the EXE file using the setup.py file and run it,
it registers the library.

When I run the VB application, it hangs at the line

Set connection = CreateObject("SAMPLE.Lib")

and displays. " ACTIVEX cannot create the object"

Any suggestions please....
Jan 8 '08 #2
On 8 Jan, 11:04, Teja <tejovath...@gmail.comwrote:
On Jan 8, 3:33 pm, Teja <tejovath...@gmail.comwrote:
Hi All,
I have a Python COM server. I need to deploy it on various sytems.
When I run the COM server from
python its showing an output " Registered : sample.lib"
If I try to use the COM obj from a VB client like:
obj = CreateObject("sample.lib")
Its working fine without any errors
Now I am trying to convert this COM server to an exe through py2exe
and after I run the exe, I am
getting the same output " Registered : sample.lib"
But If I try to use the COM obj from a VB client like
obj = CreateObject("sample.lib")
A console pops up saying " Registered : sample.lib" and VB application
hangs there.
Its throwing a VB error that "ActiveX object cannot be
created......etc etc"
Any suggestions please.......
Regards,
Tejovathi

Here is my sample COM server and py2exe setup file

testCOM.py

import win32com.client
import os.path
import shutil
from win32api import Sleep
import string
import os
import sys
import pythoncom

class FirstEx:

_reg_clsid_ = "{A6DE9DF8-5EBF-48E6-889E-C71CB84CFF2C}"
pythoncom.frozen = 1
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__.FirstEx"
_reg_desc_ = "My first COM server"
_reg_progid_ = "SAMPLE.Lib"
_public_methods_ = ['init', 'Version']
_public_attrs_ = ['softspace', 'noCalls']
_readonly_attrs_ = ['noCalls']
_reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER

def __init__(self):
self.softspace = 1
self.noCalls = 0

def Version(self):
self.noCalls = self.noCalls + 1

# insert "softspace" number of spaces
return "Version: 0.0.1"

if __name__=='__main__':
import sys
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(FirstEx)
else:
# start the server.
from win32com.server import localserver
localserver.main()
else:
import win32com.server.register
win32com.server.register.UseCommandLine(FirstEx)

Here is my setup file:

#Start here
from distutils.core import setup
import py2exe

setup(options = {"py2exe": {"compressed": 1,
"optimize": 2,
"ascii": 1,
"bundle_files": 1}},
zipfile = None,
com_server = ["win32com.servers.interp"],
console = ["testCOM.py"])
#End here

Here is my VB code:

Sub subRoutine()
Dim connection As Object
Dim returnvalue1 As String
Dim returnvalue2 As String
Dim flag3 As Boolean

Set connection = CreateObject("SAMPLE.Lib")
returnvalue1 = connection.Version()
MsgBox (returnvalue1)
End Sub

The non exe version of the COM server ie. directlly running the
testCOM.py registers the library properly and

in the VB application, the message box displays the version as 0.0.1.

But, after I create the EXE file using the setup.py file and run it,
it registers the library.

When I run the VB application, it hangs at the line

Set connection = CreateObject("SAMPLE.Lib")

and displays. " ACTIVEX cannot create the object"

Any suggestions please....
A quick suggestion (didn't read very carefully sorry).
Make sure you register it with --debug and use the pythonwin tools-
>trace collector debugging tool.
See if you get any joy. It may be you missed some vital library in
your py2exe
that causes a start-up time failure.

Giles
Jan 8 '08 #3

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

Similar topics

2
by: Phil | last post by:
I am using a Pascal like language (Wealth-Lab) on W2K and call this server: class HelloWorld: _reg_clsid_ = "{4E797C6A-5969-402F-8101-9C95453CF8F6}" _reg_desc_ = "Python Test COM Server"...
6
by: Nathan Sokalski | last post by:
I want to set up SQL Server on Windows XP Pro so that I can use the database capabilities of ASP and IIS. I am probably using some incorrect settings, but I am not sure what they are. Here is what...
9
by: Grim Reaper | last post by:
My work let me put SQL Server 7.0 Enterprise Edition on my laptop. I have never setup a server from the beginning, so I am a little new at creating server groups. Alright, I am trying to create...
0
by: Chris Halcrow | last post by:
Hi I've spent ALL DAY trying to re-install SQL Server 2000 on Windows XP. I continually get the error 'cannot configure server' just at the end of the installation. I've tried the following: ...
0
by: Zorba.GR | last post by:
IBM DB2 Connect Enterprise Edition v8.2, other IBM DB2 (32 bit, 64 bit) (MULTiOS, Windows, Linux, Solaris), IBM iSoft Commerce Suite Server Enterprise v3.2.01, IBM Tivoli Storage Resource Manager...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
14
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...

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.