ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> py2exe-users
py2exe-users
Re: [Py2exe-users] catia typelib problem
by Michael K Fox other posts by this author
Sep 21 2006 12:35PM messages near this date
Re: [Py2exe-users] catia typelib problem | [Py2exe-users] Error with Python 2.5
First, Mark, you are correct that I meant to say I'm now trying solution
1, not solution 2.

Second, you are correct that my problem was a TLB that I was directly
requesting.  I stumbled across the solution while hacking at makepy,
accidentally causing it to tell me which TLB it was unable to load.  Now
I can freeze and distribute applications that interface with CATIA !
This is awesome !


This is off-topic here, but for what it's worth this is what I did to
makepy.py:
===============
	def GenerateFromTypeLibSpec(snip):
		...snip...
		if type(typelibInfo)==type(()):
		# Tuple
		typelibCLSID, lcid, major, minor  = typelibInfo
        	#### I added this try-block around the existing code
        	# It causes py2exe to spit out an error message telling
me which typelib it couldn't find.
        	# Then I can remove that TLB from the list in setup.py
		try:
		    tlb = pythoncom.LoadRegTypeLib(typelibCLSID, major,
minor, lcid)
		    spec = selecttlb.TypelibSpec(typelibCLSID, lcid,
major, minor)
		    spec.FromTypelib(tlb, str(typelibCLSID))
		    typelibs = [(tlb, spec)]
		except:
		    typelibs = [] #### new line
================

Then, when I ran py2exe and it tried to import the gen_py modules it
threw the following error:

> >>>>>>>>>>>>>>>
	creating
C:\cygwin\usr\project\CSICM\build\bdist.win32\winexe\temp\win32com\gen_p
y
	Traceback (most recent call last):
	  File "setup.py", line 122, in ?
	    packages = ['kbe_catia']
	  File "C:\Python24\Lib\distutils\core.py", line 149, in setup
	    dist.run_commands()
	  File "C:\Python24\Lib\distutils\dist.py", line 946, in
run_commands
	    self.run_command(cmd)
	  File "C:\Python24\Lib\distutils\dist.py", line 966, in
run_command
	    cmd_obj.run()
	  File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line
218, in run
	    self._run()
	  File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line
249, in _run
	    self.typelibs)
	  File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line
1497, in collect_win32com_genpy
	    mod = gencache.GetModuleForTypelib(*info)
	  File
"C:\Python24\lib\site-packages\win32com\client\gencache.py", line 258,
in GetModuleForTypelib
	    mod = _GetModule(modName)
	  File
"C:\Python24\lib\site-packages\win32com\client\gencache.py", line 629,
in _GetModule
	    mod = __import__(mod_name)
	ImportError: No module named
D711238C-A187-4C7D-9F42-88AF6F0F0D2Ex0x0x0
> >>>>>>>>>>>>>>>>

Previously, py2exe would run without complaint, then would fail at
runtime.  But the last line above told
me what the problem really was.  I went into my setup.py and commented
out that one typelib (which 
luckily isn't one I need) then reran py2exe, and after that the frozen
executeable didn't fail at run time.


-----Original Message-----
From: Mark Hammond [mailto:mhammond@[...].au] 
Sent: Thursday, September 21, 2006 1:04 AM
To: Fox, Michael K; py2exe-users@[...].net
Subject: RE: [Py2exe-users] catia typelib problem

>   I've seen the page in the wiki 
>  <http://www.py2exe.org/index.cgi/IncludingTypelibs>
>  about this

Interestingly, the footnote of solution 2 appears incorrect.  It asserts
solution 2 itself doesn't work - but I believe it should work fine.
It's is unsuitable for some applications though, but is regardless of
py2exe.

Also, I'm a little confused about solution 3.  Solution 1 does *not*
require the typelibs to be installed on the target machine - that is the
point.  It is possible, for example, to have Office installed, but not
all the typelibs necessary to implement a plugin.  That option should
mean Python never needs to load any typelibs on the target machine (and
therefore obviously avoids depending on installed typelibs).  Regarding
newer versions of the typelib, that is only a problem if the vendor
actually breaks old interfaces - but either way, it should be possible
to include multiple versions of the same typelib.

OTOH, a problem spambayes is facing is that *developers* may not always
have all typelibs installed.  Eg, spambayes ships with files generated
from the Office2k typelibs (as that still works with newer versions of
office) - but many people only have later versions installed.  If
spambayes ships with only the newer versions, it will no longer work for
users of Office2k.  We need a strategy that allows the generated files
to be checked into source control, but still be recognised by py2exe.

I really need to document that better, with examples.

>  Now I'm trying solution 2.

Did you mean solution 1?  Solution 2 does not involve py2exe options.

>   CATIA has 102  typelibs so I pasted them all into the setup.py file:
>  	options = {"py2exe": {"typelibs":

Ack - 102!  That is amazing.

>  But then when I run py2exe I get the following error message:
>  	C:\cygwin\usr\project\CSICM>python setup.py py2exe
>  	running py2exe
>  	running build_py
>  	*** generate typelib stubs ***
>  	creating
>  C:\cygwin\usr\project\CSICM\build\bdist.win32\winexe\temp\win32com
>  	creating
>  C:\cygwin\usr\project\CSICM\build\bdist.win32\winexe\temp\win3
>  2com\gen_p
>  y
>  	Traceback (most recent call last):
>  	  File "setup.py", line 121, in ?
>  	    packages = ['kbe_catia']
>  	  File "C:\Python24\Lib\distutils\core.py", line 149, in setup
>  	    dist.run_commands()
>  	  File "C:\Python24\Lib\distutils\dist.py", line 946, in
run_commands
>  	    self.run_command(cmd)
>  	  File "C:\Python24\Lib\distutils\dist.py", line 966, in
run_command
>  	    cmd_obj.run()
>  	  File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line
218, 
>  in run
>  	    self._run()
>  	  File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line
249, 
>  in _run
>  	    self.typelibs)
>  	  File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line

>  1495, in collect_win32com_genpy
>  	    makepy.GenerateFromTypeLibSpec(info, bForDemand = False)
>  	  File
>  "C:\Python24\lib\site-packages\win32com\client\makepy.py",
>  line 194, in
>  GenerateFromTypeLibSpec
>  	    tlb = pythoncom.LoadRegTypeLib(typelibCLSID, major, minor,
>  lcid)
>  	pywintypes.com_error: (-2147312566, 'Error loading type 
>  library/DLL.', None, None)
>  
>  I googled for this error message and found this 
>  <http://mail.python.org/pipermail/python-win32/2004-September.txt> in 
>  which Mark Hammond states "typelibs can have references to other 
>  typelibs - loading one of these other references is what is failing."
>  That was back in September, 2004.   Has any solution been 
>  found for this
>  problem ?

The problem you reference has been fixed - but I don't think it applies
here.  The traceback indicates that a typelib you directly requested -
so one of the typelibs you asked for isn't installed on your machine.

Mark

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Py2exe-users mailing list
Py2exe-users@[...].net
https://lists.sourceforge.net/lists/listinfo/py2exe-users
Thread:
Michael K Fox
Mark Hammond
Michael K Fox

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved