473,606 Members | 2,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Py2Exe and a simple COM Windows Program (can't import pythoncom)

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
documentation for the py2exe tool and everything compiles ok, except
that when I run the exe, I get an exception that says "ImportErro r: no
module named pythoncom." My program used win32com (which appears to be
loaded fine with the executable) until I needed thread support for the
gui. In order to do this, I needed to import pythoncom and call
CoInitialize() and CoUninitialize( ) manually for the new thread. I
believe it is this use of the pythoncom module that py2exe is having
trouble with.

I tried adding "pythoncom" to the import list in the distutils
setup.py but the py2exe tool gave me a warning that said it couldn't
be located. I am able to import this module just fine in python
scripts and at the interpreter. I am relatively new to COM and its use
with python as well as with distutils and py2exe. If anyone could help
me out with this, it would be greatly appreciated!

Thanks,
Brian
Jul 18 '05 #1
5 3964
A quick search for pythoncom and py2exe yielded this page (which I have
actually used before so I can verify that it works):

http://aspn.activestate.com/ASPN/Mail/Message/766627

The piece of magic is, I believe, "pythoncom.froz en = 1" Hopefully this
hasn't changed too much since I last used it.

Let me know if you have troubles, I'll dig up my old scripts that I py2exe'd

Brian

Jul 18 '05 #2
Brian Kelley wrote:
A quick search for pythoncom and py2exe yielded this page (which I have
actually used before so I can verify that it works):


Oops. I think I was answering the wrong question. What I sent you was
how to py2exe a pythoncom server so I don't think that it is going to
help. Sorry about that. I'll see if I have any more notes on py2exe
and pythoncom.

Brian

Jul 18 '05 #3
hl******@uiuc.e du (Brian Hlubocky) wrote in message news:<98******* *************** ****@posting.go ogle.com>...
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
documentation for the py2exe tool and everything compiles ok, except
that when I run the exe, I get an exception that says "ImportErro r: no
module named pythoncom." My program used win32com (which appears to be
loaded fine with the executable) until I needed thread support for the
gui. In order to do this, I needed to import pythoncom and call
CoInitialize() and CoUninitialize( ) manually for the new thread. I
believe it is this use of the pythoncom module that py2exe is having
trouble with.

I tried adding "pythoncom" to the import list in the distutils
setup.py but the py2exe tool gave me a warning that said it couldn't
be located. I am able to import this module just fine in python
scripts and at the interpreter. I am relatively new to COM and its use
with python as well as with distutils and py2exe. If anyone could help
me out with this, it would be greatly appreciated!

Thanks,
Brian


Try posting a message in the PythonWin32 Mail List at ActiveState.com
It's more specific to Windows, than generic Python.
(I'm actually interested in this answer myself)
Jul 18 '05 #4
hl******@uiuc.e du (Brian Hlubocky) writes:
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
documentation for the py2exe tool and everything compiles ok, except
that when I run the exe, I get an exception that says "ImportErro r: no
module named pythoncom." My program used win32com (which appears to be
loaded fine with the executable) until I needed thread support for the
gui. In order to do this, I needed to import pythoncom and call
CoInitialize() and CoUninitialize( ) manually for the new thread. I
believe it is this use of the pythoncom module that py2exe is having
trouble with.

I tried adding "pythoncom" to the import list in the distutils
setup.py but the py2exe tool gave me a warning that said it couldn't
be located. I am able to import this module just fine in python
scripts and at the interpreter. I am relatively new to COM and its use
with python as well as with distutils and py2exe. If anyone could help
me out with this, it would be greatly appreciated!


py2exe 0.4.x is no longer compatible with the newer win32all versions,
you need the 0.5.0 prerelease for this (which requires Python 2.3, btw).

No docs so far, but samples are included - you have to modify your setup
script a little.

Thomas
Jul 18 '05 #5
Just include the 'pythoncom23.dl l'. (usally can be found in
%windir%/system32 -> Windows 2000).

Best Regards,
Kent Hsu

Brian Hlubocky <hl******@uiuc. edu> wrote in message
news:98******** *************** ***@posting.goo gle.com...
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
documentation for the py2exe tool and everything compiles ok, except
that when I run the exe, I get an exception that says "ImportErro r: no
module named pythoncom." My program used win32com (which appears to be
loaded fine with the executable) until I needed thread support for the
gui. In order to do this, I needed to import pythoncom and call
CoInitialize() and CoUninitialize( ) manually for the new thread. I
believe it is this use of the pythoncom module that py2exe is having
trouble with.

I tried adding "pythoncom" to the import list in the distutils
setup.py but the py2exe tool gave me a warning that said it couldn't
be located. I am able to import this module just fine in python
scripts and at the interpreter. I am relatively new to COM and its use
with python as well as with distutils and py2exe. If anyone could help
me out with this, it would be greatly appreciated!

Thanks,
Brian

Jul 18 '05 #6

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

Similar topics

0
2981
by: RJS | last post by:
Hi all, I can't get a py2exe compiled app to run with numarray (numarray-0.5.win32- py2.2). Also wxPythonWIN32-2.3.3.1-Py22 and ActivePython-2.2.1-222. In the sample below, commenting out "import numarray" allows the exe to run. Left in, I get "4.exe has generated errors" etc. I'm going around and around and there isn't much on Google. py2exe output is last.
5
9098
by: Giles Brown | last post by:
I'm feeling quite dumb this morning. I'm trying to build a COM server DLL using py2exe and it ain't working. Here's what ain't working... setup_dll.py based on py2exe sample: """from distutils.core import setup import py2exe
2
17662
by: x-herbert | last post by:
Hi, I have a small test to "compile" al litle script as a WMI-Tester. The script include a wmi-wrapper and "insert" the Win32-modeles. here the code: my "WMI-Tester.py" ----- import wmi
3
5705
by: Werner Merkl | last post by:
Hi, Python is really great, for small to big programs. For my colleagues and some circumstances I sometimes need to "compile" a script using py2exe. Cause I use Windows, I like to use the (Windows) ability, to add some version infos, comments, etc to the exe file. If I use explorer to check, these properties are visible and correct.
4
3584
by: Werner Merkl | last post by:
Hi, we have written a Python EXE program, which should run via AUTORUN.INF from a CD/DVD (Windows of course). For this CD/DVD we us a imaging tool from Microsoft, which seam to generate a pure ISO 9660 level 1 image.
0
2245
by: guilligan.geo | last post by:
Hello, I'm trying to create an addin for Outlook 2002 using the one provided in the demo of win32com as a starting point. I've been able to do my addin and test it if I go the "standard" way (using the python interpreter). But now, I want other poeple to use it to I want to freeze it for windows using py2exe and py2exe is giving me a headache. First, I cannot seem to be able to register my addin with the resulting executable. I've...
4
3999
by: bwaha | last post by:
First time trying to create an executable with py2exe. I have a small program which makes use of python23 (2.3.5?), wxpython ('2.6.2.1'), matplotlib ('0.83.2'), win32com (latest?), Numeric ('23.7') on Windows XP & Win2000. The program runs without problem but as an exe it doesn't even get to showing the GUI. I get the following error log when I run the executable. Traceback (most recent call last): File "mpival3.py", line 1264, in ?
6
4754
by: zdp | last post by:
Dear all: I made a window program by wxPython. Split windows, treectrl, listctrl and textctrl are used. When I program in python, the look & feel of the window controls are like the windos XP look & feel, with thin and flat border (My os is window XP). It's natural because, as I know, wxPython use native look and feel. But when I convert the program to EXE file by Py2exe, and run it, the look & feel is bad. It's just like the windows...
5
2609
by: DarkPearl | last post by:
Bonjour à tous, apres avoir créer un service windows avec py2exe, j'ai ce probleme quand je lance le service : voici ce que je trouve dans le journal d'evenement : The instance's SvcRun() method failed <Error getting traceback - traceback.print_tb() failed <class 'pywintypes.com_error'>: (-2147221020, 'Syntaxe incorrecte',
0
8045
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7981
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8462
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8127
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6803
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5994
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5470
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1315
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.