Faulty Build

14 views
Skip to first unread message

gurry

unread,
Sep 26, 2010, 2:27:24 AM9/26/10
to DreamPie
Hi,

I've built DreamPie on my computer and then installed it using the
resulting installer. Now when I click 'Add Interpreter', shortcut
creation fails with the following error:

Traceback (most recent call last):
File "create-shortcuts.py", line 60, in <module>
ImportError: cannot import name IWshRuntimeLibrary

I had comtypes already installed before I built DreamPie. I don't know
why this particular module cannot be imported. Could you guys suggest
how I must change my build environment to get rid of this problem?

Thanks and regards,
Gurinder

Noam Yorav-Raphael

unread,
Sep 26, 2010, 11:13:45 AM9/26/10
to drea...@googlegroups.com
Hello,

Which version of comtypes are you using? The newest one (0.6.2)
includes a module with that name. Maybe you should download a newer
one.

Noam

gurry

unread,
Oct 9, 2010, 11:00:21 PM10/9/10
to DreamPie
Hi Noam,

Thanks for your reply.

Yes, 0.6.2 is what I've got. I think the problem is that
IWshRuntimeLibrary is a part of a generated code, but this code is not
being generated on my machine. I say that because the comtypes/gen
folder in my site-packages contains nothing except the __init__.py and
this file too is completely empty.

So my actual hurdle now is, how do I get comtypes to generate code?
I've seen a codegenerator.py in comptypes installation, but I'm not
sure how to use it. Also, should it not have run automagically when I
installed the package?

This may not be the right forum for these questions, but still if you
could give me a nudge in the right direction I'll be much obliged.

Thanks and regards,
Gurinder

gurry

unread,
Oct 9, 2010, 11:02:58 PM10/9/10
to DreamPie
By the way, forgot to mention that I've searched a good deal for this
this code generation thing but couldn't find any clear answer on the
Internet.

Noam Yorav-Raphael

unread,
Oct 10, 2010, 2:58:24 AM10/10/10
to drea...@googlegroups.com
Did you use "setup.py install"? I guess it would do the trick.

gurry

unread,
Oct 10, 2010, 10:19:30 AM10/10/10
to DreamPie
No Noam. For some unknown reason, that didn't work either. However, I
found that comtypes.client.GetModule() generates a wrapper when
called. So the following code did the job:

import glob
import os

#Generates wrapper for a given library
def wrap(com_lib):
try:
comtypes.client.GetModule(com_lib)
except:
print "Failed to wrap {0}".format(com_lib)


sys32dir = os.path.join(os.environ["SystemRoot"], "system32")

#Generate wrappers for all ocx's system32
for lib in glob.glob(os.path.join(sys32dir, "*.ocx")):
wrap(lib)

#Generate for all dll's in system32
for lib in glob.glob(os.path.join(sys32dir, "*.tlb")):
wrap(lib)

Having the relevant com lib wrapped, now I can access
IWshRuntimeLibrary just fine.

Thank you for your help all along.

Regards,
Gurinder

Noam Yorav-Raphael

unread,
Oct 10, 2010, 10:32:18 AM10/10/10
to drea...@googlegroups.com
Great, I'm happy it worked at the end.

Noam

Noam Yorav-Raphael

unread,
Oct 18, 2010, 4:50:39 PM10/18/10
to drea...@googlegroups.com
Ok, I figured out what was wrong. I adopted a script I've found, which had this:

from comtypes.client import CreateObject
ws = CreateObject("WScript.Shell")
from comtypes.gen import IWshRuntimeLibrary

I then moved the second line into functions, and left the third line (because it's an import line). The third line depends on the second line to create the generated file, but it worked for me because the file has already been generated when I run the script the first time.

I fixed it in the repository (revision 199). Thanks for reporting this!

Have a good day,
Noam
Reply all
Reply to author
Forward
0 new messages