Trouble using PyInstaller with win32com and/or iTunes COM interface

422 views
Skip to first unread message

unknownmat

unread,
Aug 27, 2007, 6:34:20 PM8/27/07
to PyInstaller
Hello,

A GUI application that I use to manipulate iTunes, runs correctly
using the Python interpreter. The PyInstaller generated executable,
however, gives me errors. I am fairly certain that the problem that I
am having is due to how win32com and PyInstaller interact - and to be
fair, it is likely due to my own ignorance thereof.

I use PythonCard for my GUI library . After working through the
PythonCard tutorial on building standalone apps (http://
pythoncard.sourceforge.net/standalone.html), PythonCard appears to
work correctly.

For win32com, I seem to be running into issues getting PyInstaller to
generate (or "freeze" perhaps?) the required interfaces. For example,
in my original app, I connected to iTunes by:
iTunes =
win32com.client.gencache.EnsureDispatch( "iTunes.Application" )

However, running the PyInstaller generated executable resulted in:
ImportError: No module named win32com.gen_py.9E93C96F-CF0D-43F6-8BA8-
B807A3370712x0x1x9

Then, after reading through the PyInstaller Manual (http://
pyinstaller.python-hosting.com/file/trunk/doc/Manual.html?
rev=latest&format=raw), I changed that line to:
iTunes = win32com.client.Dispatch('iTunes.Application',
clsctx=pythoncom.CLSCTX_LOCAL_SERVER)

This works successfully, although I don't understand what the
difference is. Unfortunately, I have run into another error that I
cannot fix:

for track in iTunes.LibraryPlaylist.Tracks:
file_track = win32com.client.CastTo( track, 'IITFileOrCDTrack' )

I need to cast the IITTrack object to a IITFileOrCDTrack object, so
that I can look at the IITFileOrCDTrack "Location" property.
Unfortunately, the CastTo() call generates the same error as above.

Does anybody have any experience with using win32com who might be able
to help me? Any help would certainly be appreciated.

Thanks,
Matt

p.s. Since I am only using the COM objects as a client, I don't
believe the "Windows COM Server Support" section in the PyInstaller
Manual is useful to me. Is this correct?

p.p.s. The PyInstaller manual has a section that mentions a hook
required to use win32com:
http://pyinstaller.python-hosting.com/file/trunk/doc/Manual.html?rev=latest&format=raw#changing-runtime-behavior.
Is this something that I need to be concerned about? What is this
hook, and how do I use it?

unknownmat

unread,
Sep 6, 2007, 10:26:50 PM9/6/07
to PyInstaller
> required to use win32com:http://pyinstaller.python-hosting.com/file/trunk/doc/Manual.html?rev=....

> Is this something that I need to be concerned about? What is this
> hook, and how do I use it?


In case anybody is interested, I found an answer at the following
location:
http://osdir.com/ml/python.pyinstaller/2006-02/msg00069.html

Apparently there was a patch submitted Februrary 2006.

Using the fix suggested by the author, I was able to use
win32com.client.gencache.EnsureDispatch(), as well as
win32com.client.CastTo(), without any trouble.

Matt

Reply all
Reply to author
Forward
0 new messages