On dom, 2009-05-10 at 21:13 +0000, Pyinstaller wrote:

> When run on the build system ''as an
>  executable'', we get the following output:
> 
>  {{{
>  <module 'encodings' from '/usr/lib/python2.6/encodings/__init__.pyc'>
>  ['CodecRegistryError', '__builtin__', '__builtins__', '__doc__',
>  '__file__',
>  '__name__', '__package__', '__path__', '_aliases', '_cache',
>  '_import_tail',
>  '_norm_encoding_map', '_unknown', 'aliases', 'codecs',
>  'normalize_encoding', 'search_function', 'utf_8']
>  <module 'encodings.utf_8' from '/usr/lib/python2.6/encodings/utf_8.pyc'>
>  '\xe2\x80\xa9'
>  }}}
> 
>  which again doesn't seem unreasonable.

No, this is wrong: you can see that it is importing "encodings"
from /usr/lib, instead of using the version within the executable.

>  However, copying the executable to
>  a different system (Ubuntu Hardy/python2.5) and running it there gives the
>  following output:
> 
>  {{{
>  <module 'encodings' from
>  
> '/home/vinay/projects/py_scratch/build/pyi.linux2/munge/outPYZ1.pyz/encodings'>
>  ['CodecRegistryError', '__builtin__', '__builtins__', '__doc__',
>  '__file__',
>  '__importsub__', '__name__', '__package__', '__path__', '_aliases',
>  '_cache', '_import_tail',
>  '_norm_encoding_map', '_unknown', 'aliases', 'codecs',
>  'normalize_encoding', 'search_function']
>  Traceback (most recent call last):
>    File "<string>", line 10, in <module>
>    File "<string>", line 6, in main
>  AttributeError: 'module' object has no attribute 'utf_8'
>  }}}
> 
>  Now fails, because for whatever reason, 'utf_8' has not been auto-imported
>  as it was in the two previous cases. The same error occurs when building
>  on Ubuntu Hardy/python2.5 and copying to Ubuntu Jaunty/python2.6.

The fact that it is not auto-imported does not seem a mistake per-se. I
don't think you should rely on the fact that, whenever you import
"encodings", "encodings.utf_8" gets automatically imported as well
(without having explicitly used utf-8 before).

What happens if you instead swap the last two lines in your sample
program, that is:

===========================================================
 import encodings

 def main():
     print encodings
     print dir(encodings)
     print repr(u'\u2029'.encode('utf-8'))   # swapped
     print encodings.utf_8                   # swapped

 if __name__ == "__main__":
     main()
===========================================================

Does it work now?
-- 
Giovanni Bajo
Develer S.r.l.
http://www.develer.com



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/PyInstaller?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to