[python-win32] Re: py2exe runtime problem...

Eric Walstad eric at ericwalstad.com
Tue May 20 12:31:35 EDT 2003


Hi Thomas,
Thanks for the reply and help with debugging the problem.  See below for 
details.

Thomas Heller wrote:
> Eric Walstad <eric at ericwalstad.com> writes:
> 
> 
>>I didn't see any py2exe list, and I saw other posts on the subject in
>>the archives, so I'm posting my question here.
>>
>>
>>I have a little app consisting of 3 py files that I'm trying use with
>>py2exe.  I get a couple of "compile-time" warnings from py2exe (see
>>below) but no errors.  When I run the reuslting exe file I get a
>>"IOError: invalid mode:" run-time error (see traceback below).
>>
>>
>>If anyone can point me toward possible culptits, I'd sure appreciate it.
>>
>>Thanks VERY much for your time!
>>
>>Eric.
>>
>>##################  BEGIN TRACEBACK  ##################
>>
>>C:\Documents and Settings\ewalstad\My Documents\ew\2003\pl\kiosk\plJoin\di
>>st\Aggregator>aggregator.exe
>>Traceback (most recent call last):
>>   File "<string>", line 8, in ?
>>   File "imputil.pyc", line 103, in _import_hook
>>   File "<string>", line 52, in _import_top_module
>>   File "imputil.pyc", line 216, in import_top
>>   File "imputil.pyc", line 271, in _import_one
>>   File "<string>", line 128, in _process_result
>>   File "Serializer.pyc", line 2, in ?
>>   File "imputil.pyc", line 103, in _import_hook
>>   File "<string>", line 52, in _import_top_module
>>   File "imputil.pyc", line 216, in import_top
>>   File "imputil.pyc", line 267, in _import_one
>>   File "<string>", line 161, in get_code
>>IOError: invalid mode:
> 
> 
> The "<string>" above refers to the code in
> lib/site-packages/py2exe/support.py. Around line 161, there is this:
> 
>         info = _extensions_mapping.get(fqname)
>         if info:
>             pathname, desc = info
>             # prepend exe_dir to filename
>             pathname = "%s\\%s" % (sys.prefix, pathname)
>             # Should catch IOError and convert into ImportError ??
> (161)       fp = open(pathname, desc[1])
>             dict['__file__'] = pathname
>             return 0, imp.load_module(fqname, fp, pathname, desc), dict
> 
> Can you insert some print statements before this line to see what's
> going wrong? I'm concerned about the comment before this line.

OK, here's how I changed the support.py file:
info = _extensions_mapping.get(fqname)
print "*******************************************************"
print "DEBUG-> parent, modname, fqname, get_code, _pyc_suffix:", parent, 
modname, fqname, get_code, _pyc_suffix
print "DEBUG-> info:", info
if info:
     pathname, desc = info
     print "DEBUG-> pathname, desc:", pathname, desc
     # prepend exe_dir to filename
     pathname = "%s\\%s" % (sys.prefix, pathname)
     print "DEBUG-> sys.prefix\pathname:", pathname
     # Should catch IOError and convert into ImportError ??
     print "DEBUG-> desc[1]:", desc[1]
     print "DEBUG-> *** ABOUT TO OPEN FILE..."
     fp = open(pathname, desc[1])
     print "DEBUG-> *** FILE OPENED, fp:", fp
     dict['__file__'] = pathname
     imp_loadmodule = imp.load_module(fqname, fp, pathname, desc)
     print "DEBUG-> imp_loadmodule:", imp_loadmodule
     print "DEBUG-> dict:", dict
     return 0, imp_loadmodule, dict


And here's the output and traceback.  I looked for 
"_extensions_mapping," as it appears to be when the _pyc_suffix info is 
lost, but couldn't find it in my Python22 dir.


C:\Documents and Settings\ewalstad\My 
Documents\ew\2003\pl\kiosk\plJoin\dist\Aggregator>aggregator.exe
*******************************************************
DEBUG-> parent, modname, fqname, get_code, _pyc_suffix: None csiSplit 
csiSplit <built-in function get_code> ('.pyc', 'rb', 2)
DEBUG-> info: None
*******************************************************
DEBUG-> parent, modname, fqname, get_code, _pyc_suffix: None os os 
<built-in function get_code> ('.pyc', 'rb', 2)
DEBUG-> info: None
*******************************************************
DEBUG-> parent, modname, fqname, get_code, _pyc_suffix: None ntpath 
ntpath <built-in function get_code> ('.pyc', 'rb', 2)
DEBUG-> info: None
*******************************************************
DEBUG-> parent, modname, fqname, get_code, _pyc_suffix: None stat stat 
<built-in function get_code> ('.pyc', 'rb', 2)
DEBUG-> info: None
*******************************************************
DEBUG-> parent, modname, fqname, get_code, _pyc_suffix: None UserDict 
UserDict <built-in function get_code> ('.pyc', 'rb', 2)
DEBUG-> info: None
*******************************************************
DEBUG-> parent, modname, fqname, get_code, _pyc_suffix: None copy_reg 
copy_reg <built-in function get_code> ('.pyc', 'rb', 2)
DEBUG-> info: None
*******************************************************
DEBUG-> parent, modname, fqname, get_code, _pyc_suffix: None types types 
<built-in function get_code> ('.pyc', 'rb', 2)
DEBUG-> info: None
*******************************************************
DEBUG-> parent, modname, fqname, get_code, _pyc_suffix: None __future__ 
__future__ <built-in function get_code> ('.pyc', 'rb', 2)
DEBUG-> info: None
*******************************************************
DEBUG-> parent, modname, fqname, get_code, _pyc_suffix: None shutil 
shutil <built-in function get_code> ('.pyc', 'rb', 2)
DEBUG-> info: None
*******************************************************
DEBUG-> parent, modname, fqname, get_code, _pyc_suffix: None csv csv 
<built-in function get_code> ('.pyc', 'rb', 2)
DEBUG-> info: ('csv.pyd', ('.pyd', 'rb', 3))
DEBUG-> pathname, desc: csv.pyd ('.pyd', 'rb', 3)
DEBUG-> sys.prefix\pathname: C:\Documents and Settings\ewalstad\My 
Documents\ew\2003\pl\kiosk\plJoin\dist\Aggregator\csv.pyd
DEBUG-> desc[1]: rb
DEBUG-> *** ABOUT TO OPEN FILE...
DEBUG-> *** FILE OPENED, fp: <open file 'C:\Documents and 
Settings\ewalstad\My 
Documents\ew\2003\pl\kiosk\plJoin\dist\Aggregator\csv.pyd', mode 'rb' at 
0x0094DB
E0>
DEBUG-> imp_loadmodule: <module 'csv' from 'C:\Documents and 
Settings\ewalstad\My 
Documents\ew\2003\pl\kiosk\plJoin\dist\Aggregator\csv.pyd'>
DEBUG-> dict: {'__file__': 'C:\\Documents and Settings\\ewalstad\\My 
Documents\\ew\\2003\\pl\\kiosk\\plJoin\\dist\\Aggregator\\csv.pyd'}
*******************************************************
DEBUG-> parent, modname, fqname, get_code, _pyc_suffix: None Serializer 
Serializer <built-in function get_code> ('.pyc', 'rb', 2)
DEBUG-> info: None
*******************************************************
DEBUG-> parent, modname, fqname, get_code, _pyc_suffix: None sqlite 
sqlite <built-in function get_code> ('.pyc', 'rb', 2)
DEBUG-> info: ('sqlite.dll', ('', '', 5))
DEBUG-> pathname, desc: sqlite.dll ('', '', 5)
DEBUG-> sys.prefix\pathname: C:\Documents and Settings\ewalstad\My 
Documents\ew\2003\pl\kiosk\plJoin\dist\Aggregator\sqlite.dll
DEBUG-> desc[1]:
DEBUG-> *** ABOUT TO OPEN FILE...
Traceback (most recent call last):
   File "<string>", line 8, in ?
   File "imputil.pyc", line 103, in _import_hook
   File "<string>", line 52, in _import_top_module
   File "imputil.pyc", line 216, in import_top
   File "imputil.pyc", line 271, in _import_one
   File "<string>", line 128, in _process_result
   File "Serializer.pyc", line 4, in ?
   File "imputil.pyc", line 103, in _import_hook
   File "<string>", line 52, in _import_top_module
   File "imputil.pyc", line 216, in import_top
   File "imputil.pyc", line 267, in _import_one
   File "<string>", line 168, in get_code
IOError: invalid mode:





More information about the Python-win32 mailing list