473,320 Members | 1,838 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,320 software developers and data experts.

Need a little more help with py2exe/COM problem.

Hello,

I've fiddled with this for quite a while and thought I had the problem
solved. I had a version that would successfully compile and run. But
then I had to change the code to use a different module, and now it
will compile but not run again.

I know that functionality in this area is not fully supported yet, but
there has to be someone out there that has got this to work. I am
using Python2.3, with py2exe 0.4.2, and win32all 159. The fact that
this works with one module and not the other is very confusing.

WHAT WORKED
===========
import win32com.client
import win32com.client.dynamic
import os, os.path

class easyExcel:
def __init__(self, filename=None):
self.xlApp =
win32com.client.dynamic.Dispatch('Excel.Applicatio n')
self.filename = filename
...much more stuff...

WHAT DOESN'T WORK
=================
import win32com.client
import win32com.client.dynamic
import os, os.path

class ExcelEvents:
def getHandle(self, ee):
self.ee = ee
def OnWorkbookBeforeClose(self, wb, wn):
if self.ee.active():
print "WORKBOOK IS ACTIVE"
self.ee.hide()
return 1
else:
print "WORKBOOK IS NOT ACTIVE"
return 0

class easyExcel:
def __init__(self, filename=None):
self.xlApp =
win32com.client.dynamic.Dispatch('Excel.Applicatio n')
x_events = win32com.client.WithEvents( self.xlApp, ExcelEvents
)
x_events.getHandle(self)
For some reason when I use the *dynamic* module, I am able to freeze
and run perfectly. However, when I use the *client* module functions,
I get the following error:

ImportError: No module named
win32com.gen_py.00020813-0000-0000-C000-00000000004
6x0x1x4

I get the same error if I use "DispatchWithEvents" from the *client*
module instead of using "Dispatch" and "WithEvents".

Does anyone know why this happens? Why does it work with one module
and not the other one? And is there something special I need to do
while running py2exe to include this module?

Thanks ahead of time for any help,
Marc
Jul 18 '05 #1
1 3833
Just in case anyone else runs into the same problem, I will post what I got
to work so far.

With Py2.3, py2exe 0.4.2, and win32all 157, I was able to get it to work
doing the following (all of which I had done at one point or another, but
not in the correct order or after I had tried a different version).

Make sure and run makepy.py on Excel.
Compiled with the command: python setup.py py2exe --program
"Excel.Application"

That seemed to work. However I couldn't get it to work using these steps
with win32all 159, and I did create the gen_py directory manually under
win32com.client before running makepy.

"Marc" <mn******@airmail.net> wrote in message
news:43**************************@posting.google.c om...
Hello,

I've fiddled with this for quite a while and thought I had the problem
solved. I had a version that would successfully compile and run. But
then I had to change the code to use a different module, and now it
will compile but not run again.

I know that functionality in this area is not fully supported yet, but
there has to be someone out there that has got this to work. I am
using Python2.3, with py2exe 0.4.2, and win32all 159. The fact that
this works with one module and not the other is very confusing.

WHAT WORKED
===========
import win32com.client
import win32com.client.dynamic
import os, os.path

class easyExcel:
def __init__(self, filename=None):
self.xlApp =
win32com.client.dynamic.Dispatch('Excel.Applicatio n')
self.filename = filename
...much more stuff...

WHAT DOESN'T WORK
=================
import win32com.client
import win32com.client.dynamic
import os, os.path

class ExcelEvents:
def getHandle(self, ee):
self.ee = ee
def OnWorkbookBeforeClose(self, wb, wn):
if self.ee.active():
print "WORKBOOK IS ACTIVE"
self.ee.hide()
return 1
else:
print "WORKBOOK IS NOT ACTIVE"
return 0

class easyExcel:
def __init__(self, filename=None):
self.xlApp =
win32com.client.dynamic.Dispatch('Excel.Applicatio n')
x_events = win32com.client.WithEvents( self.xlApp, ExcelEvents
)
x_events.getHandle(self)
For some reason when I use the *dynamic* module, I am able to freeze
and run perfectly. However, when I use the *client* module functions,
I get the following error:

ImportError: No module named
win32com.gen_py.00020813-0000-0000-C000-00000000004
6x0x1x4

I get the same error if I use "DispatchWithEvents" from the *client*
module instead of using "Dispatch" and "WithEvents".

Does anyone know why this happens? Why does it work with one module
and not the other one? And is there something special I need to do
while running py2exe to include this module?

Thanks ahead of time for any help,
Marc

Jul 18 '05 #2

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

Similar topics

0
by: Kathleen Kudzma | last post by:
I'm having a problem with py2exe for Python 2.3. I got fixed the Lookuperror no codec search functions registered: can't find encoding by following the instructions on the py2exe page (added...
8
by: Kathleen Kudzma | last post by:
Does anyone know how to resolve the following problem that I'm getting in Python 2.2 and 2.3? PROBLEM: When I try to create a classReader object I get an exception: "SAXReaderNotAvailable: No...
0
by: bapeterson | last post by:
I'd like to use PY2EXE to "compile" a program using the VPYTHON module (www.vpython.org). I have an example where this was previously done to the demo script: Hanoi.py (a towers of Hanoi demo) a...
6
by: Luc Saffre | last post by:
Hello, I had a strange problem when freezing (using either py2exe or McMillan installer) a script that imports reportlab (which imports PIL (which imports FixTk))). - Python 2.3.3c (also with...
5
by: Tim Axtelle | last post by:
I am new to Python and am trying to create a standalone exe from a python script using py2exe 0.5.0 and Python 2.3 without success. I am able to generate the appropriate .exe file but it is not...
0
by: upward_spiral2001 | last post by:
Hi. I've got a neat artificial intelligence project I want to distribute as an EXE. I'm using Python, Pygame, and Numeric. My problem is: When I use py2exe, I'm told "The following modules appear...
0
by: kschnee | last post by:
Hi. I've got a neat artificial intelligence project I want to distribute as an EXE. I'm using Python, Pygame, and Numeric. My problem is: When I use py2exe, I'm told "The following modules appear...
5
by: msunderwd | last post by:
Having a problem with "compiling" a Tkinter/python program using py2exe (and pyinstaller, for that matter)... I have several dialogs that are derived from the tkSimpleDialog.Dialog class. These...
5
by: jmDesktop | last post by:
Hi, I would like to start using Python, but am unsure where to begin. I know how to look up a tutorial and learn the language, but not what all technologies to use. I saw references to plain...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.