import OpenGL.GL
print "hello"
gives error
Traceback (most recent call last):
File "<string>", line 3, in ?
File "E:\pyinstaller\iu.py", line 334, in importHook
ImportError: No module named encodings
It does not depend on -F/-D choice in Makespec.py.
This is on winxp, created with python 2.4, PyOpenGL 2.0.1.09,
pyinstaller from svn (today).
The error message appears on a machine with no python 2.4 installed.
(there actually is python 2.5, but hopefully it doesn't matter). If I
install python 2.4 there (vanilla, no PyOpenGL installation required)
the error disappears.
Best regards
P.
I still can't reproduce this, but I'm willing to try and debug it. I need some
help though.
First, can you run ArchiveViewer onto the final executable, type "O out1.pyz"
to open the internal PYZ file, and then see if the encodings packages is
present in the list? I'll paste my session to show you what I mean:
[E:\work\pyinstaller\bug\distopenglbug]..\..\ArchiveViewer.py openglbug.exe
pos, length, uncompressed, iscompressed, type, name
[(0, 284573, 284573, 0, 'z', 'out1.pyz'),
(284573, 6954, 15937, 1, 'm', 'iu'),
(291527, 5276, 12167, 1, 'm', 'archive'),
(296803, 597, 1035, 1, 's', '_mountzlib'),
(297400, 1153, 2307, 1, 's', 'opengl'),
(298553, 81, 76, 1, 's', 'useUnicode'),
(298634, 41, 33, 1, 's', 'openglbug')]
? O out1.pyz
Name: (ispkg, pos, len)
{'OpenGL': (True, 991L, 686),
'OpenGL.GL': (True, 16L, 338),
'OpenGL.GL.GL__init__': (False, 197808L, 15767),
'OpenGL.GLU': (True, 225247L, 250),
'OpenGL.GLU.GLU__init__': (False, 185162L, 3177),
'StringIO': (False, 1677L, 4606),
'UserDict': (False, 83234L, 2663),
'base64': (False, 10825L, 4414),
'codecs': (False, 102803L, 8080),
'copy': (False, 176083L, 5078),
'copy_reg': (False, 226769L, 2380),
'dis': (False, 48408L, 3099),
'encodings': (True, 63465L, 1965),
'encodings.aliases': (False, 214221L, 2976),
'encodings.ascii': (False, 270545L, 557),
'encodings.base64_codec': (False, 29602L, 1029),
'encodings.big5': (False, 8421L, 639),
'encodings.big5hkscs': (False, 190666L, 643),
'encodings.bz2_codec': (False, 142991L, 1063),
'encodings.charmap': (False, 168720L, 796),
'encodings.cp037': (False, 27274L, 2328),
'encodings.cp1006': (False, 171001L, 1610),
'encodings.cp1026': (False, 85897L, 2342),
'encodings.cp1140': (False, 10133L, 692),
'encodings.cp1250': (False, 245456L, 1473),
'encodings.cp1251': (False, 243689L, 1767),
'encodings.cp1252': (False, 242623L, 1066),
'encodings.cp1253': (False, 240951L, 1672),
'encodings.cp1254': (False, 239839L, 1112),
'encodings.cp1255': (False, 238257L, 1582),
'encodings.cp1256': (False, 236723L, 1534),
'encodings.cp1257': (False, 235220L, 1503),
'encodings.cp1258': (False, 234030L, 1190),
'encodings.cp424': (False, 173721L, 2362),
'encodings.cp437': (False, 154531L, 1794),
'encodings.cp500': (False, 188339L, 2327),
'encodings.cp737': (False, 160950L, 1871),
'encodings.cp775': (False, 15239L, 1817),
'encodings.cp850': (False, 58621L, 1715),
'encodings.cp852': (False, 56785L, 1836),
'encodings.cp855': (False, 54917L, 1868),
'encodings.cp856': (False, 53226L, 1691),
'encodings.cp857': (False, 51507L, 1719),
'encodings.cp860': (False, 266034L, 1787),
'encodings.cp861': (False, 267821L, 1798),
'encodings.cp862': (False, 30631L, 1849),
'encodings.cp863': (False, 264236L, 1798),
'encodings.cp864': (False, 260580L, 1860),
'encodings.cp865': (False, 262440L, 1796),
'encodings.cp866': (False, 255602L, 1872),
'encodings.cp869': (False, 253748L, 1854),
'encodings.cp874': (False, 140016L, 1764),
'encodings.cp875': (False, 137497L, 2519),
'encodings.cp932': (False, 354L, 637),
'encodings.cp949': (False, 250238L, 638),
'encodings.cp950': (False, 278213L, 639),
'encodings.euc_jis_2004': (False, 156325L, 645),
'encodings.euc_jisx0213': (False, 122435L, 645),
'encodings.euc_jp': (False, 226134L, 635),
'encodings.euc_kr': (False, 24036L, 634),
'encodings.gb18030': (False, 275010L, 645),
'encodings.gb2312': (False, 40153L, 638),
'encodings.gbk': (False, 67145L, 638),
'encodings.hex_codec': (False, 250876L, 1038),
'encodings.hp_roman8': (False, 169516L, 1485),
'encodings.hz': (False, 225497L, 637),
'encodings.idna': (False, 271753L, 1995),
'encodings.iso2022_jp': (False, 77422L, 646),
'encodings.iso2022_jp_1': (False, 100302L, 648),
'encodings.iso2022_jp_2': (False, 101598L, 647),
'encodings.iso2022_jp_2004': (False, 123080L, 653),
'encodings.iso2022_jp_3': (False, 100950L, 648),
'encodings.iso2022_jp_ext': (False, 6921L, 651),
'encodings.iso2022_kr': (False, 213575L, 646),
'encodings.iso8859_1': (False, 43173L, 750),
'encodings.iso8859_10': (False, 183970L, 1192),
'encodings.iso8859_11': (False, 182439L, 1531),
'encodings.iso8859_13': (False, 181161L, 1278),
'encodings.iso8859_14': (False, 9060L, 1073),
'encodings.iso8859_15': (False, 7572L, 849),
'encodings.iso8859_16': (False, 172611L, 1110),
'encodings.iso8859_2': (False, 41884L, 1289),
'encodings.iso8859_3': (False, 40791L, 1093),
'encodings.iso8859_4': (False, 127937L, 1225),
'encodings.iso8859_5': (False, 46820L, 1588),
'encodings.iso8859_6': (False, 45397L, 1423),
'encodings.iso8859_7': (False, 43923L, 1474),
'encodings.iso8859_8': (False, 38913L, 1240),
'encodings.iso8859_9': (False, 71225L, 815),
'encodings.johab': (False, 6283L, 638),
'encodings.koi8_r': (False, 78068L, 1872),
'encodings.koi8_u': (False, 79940L, 860),
'encodings.latin_1': (False, 163378L, 562),
'encodings.mac_cyrillic': (False, 247397L, 1844),
'encodings.mac_greek': (False, 68434L, 1828),
'encodings.mac_iceland': (False, 65430L, 1715),
'encodings.mac_latin2': (False, 251914L, 1834),
'encodings.mac_roman': (False, 147718L, 1726),
'encodings.mac_turkish': (False, 80800L, 1730),
'encodings.mbcs': (False, 276174L, 621),
'encodings.palmos': (False, 70262L, 963),
'encodings.ptcp154': (False, 115791L, 1804),
'encodings.punycode': (False, 144567L, 3151),
'encodings.quopri_codec': (False, 249241L, 997),
'encodings.raw_unicode_escape': (False, 275655L, 519),
'encodings.rot_13': (False, 141780L, 1211),
'encodings.shift_jis': (False, 17056L, 641),
'encodings.shift_jis_2004': (False, 67783L, 651),
'encodings.shift_jisx0213': (False, 271102L, 651),
'encodings.string_escape': (False, 246929L, 468),
'encodings.tis_620': (False, 127158L, 779),
'encodings.undefined': (False, 82530L, 704),
'encodings.unicode_escape': (False, 144054L, 513),
'encodings.unicode_internal': (False, 197294L, 514),
'encodings.utf_16': (False, 156970L, 1082),
'encodings.utf_16_be': (False, 162821L, 557),
'encodings.utf_16_le': (False, 102245L, 558),
'encodings.utf_7': (False, 17697L, 457),
'encodings.utf_8': (False, 24670L, 551),
'encodings.uu_codec': (False, 114065L, 1726),
'encodings.zlib_codec': (False, 123733L, 1029),
'getopt': (False, 257474L, 3106),
'inspect': (False, 88239L, 12063),
'linecache': (False, 276795L, 1418),
'ntpath': (False, 72267L, 5155),
'opcode': (False, 124762L, 2396),
'os': (False, 129162L, 8335),
'os2emxpath': (False, 32480L, 4389),
'popen2': (False, 60336L, 3129),
'posixpath': (False, 149444L, 5087),
'quopri': (False, 110883L, 3182),
're': (False, 72040L, 227),
'repr': (False, 25221L, 2053),
'sre': (False, 117595L, 4840),
'sre_compile': (False, 229149L, 4881),
'sre_constants': (False, 158052L, 2898),
'sre_parse': (False, 217197L, 8050),
'stat': (False, 269619L, 926),
'string': (False, 18154L, 5882),
'stringprep': (False, 191309L, 5985),
'token': (False, 36869L, 2044),
'tokenize': (False, 163940L, 4780),
'types': (False, 273748L, 1262)}
? Q
As you can see, the "encondings" package is present within my executable.
Let's start from this.
--
Giovanni Bajo
> [snip]
Yes, I have all the encoding packages there. If you have time etc.
for this, let me know what other tests I should do. (I hope this bug
is not caused by some stupidity on my part, but since other people
reported it..)
Best regards
P.
>> First, can you run ArchiveViewer onto the final executable, type "O out1.pyz"
>> to open the internal PYZ file, and then see if the encodings packages is
>> present in the list? I'll paste my session to show you what I mean:
>> [snip]
>
> Yes, I have all the encoding packages there.
Can you compare the full list of modules I posted to the mailing list to the
list of modules produced on your computer? Is there any difference?
Go to iu.py, importHook() function at line 274. There are several commented
print statements in the function. Uncomment them, rebuild the executable, and
show the full output produced by it.
Thanks!
--
Giovanni Bajo
The list of modules is identical. Here is what I get with those print
statements uncommented:
importHook(encodings, __main__, locals, None)
importHook trying encodings in None
importHook(imp, archive, locals, None)
importHook trying imp in None
importHook done with imp archive None (case 2)
importHook(os, __main__, locals, None)
importHook trying os in None
importHook(imp, archive, locals, None) <-----here
importHook trying imp in None
importHook done with imp archive None (case 2)
importHook(os, __main__, locals, None)
importHook trying os in None
Traceback (most recent call last):
File "<string>", line 3, in ?
File "F:\pyinstaller\iu.py", line 334, in importHook
raise ImportError, "No module named %s" % fqname
ImportError: No module named encodings
Don't know if it helps, but when python2.4 is installed on the
computer (and thus everything works), the marked line is
importHook done with os __main__ None (case 2)
I noticed that in support\rthooks there is a file opengl.py and it is
not compiled to a pyc, so it was never imported (does it mean that I
forgot some switch?).
Best regards
P.
> The list of modules is identical. Here is what I get with those print
> statements uncommented:
>
> importHook(encodings, __main__, locals, None)
> importHook trying encodings in None
> importHook(imp, archive, locals, None)
> importHook trying imp in None
> importHook done with imp archive None (case 2)
> importHook(os, __main__, locals, None)
> importHook trying os in None
> importHook(imp, archive, locals, None) <-----here
> importHook trying imp in None
> importHook done with imp archive None (case 2)
> importHook(os, __main__, locals, None)
> importHook trying os in None
> Traceback (most recent call last):
> File "<string>", line 3, in ?
> File "F:\pyinstaller\iu.py", line 334, in importHook
> raise ImportError, "No module named %s" % fqname
> ImportError: No module named encodings
>
> Don't know if it helps, but when python2.4 is installed on the
> computer (and thus everything works), the marked line is
> importHook done with os __main__ None (case 2)
Right. It looks like the module "os" is executing an import statement. The
only optional import statement I can see in os.py is:
# Change environ to automatically call putenv() if it exists
try:
# This will fail if there's no putenv
putenv
except NameError:
pass
else:
import UserDict <<------------ HERE
But I can't see how that might change between having and not having a Python
installed.
Next step is to find out what's going on while importing "os". Basically after
this line:
importHook trying os in None
it should start importing os.py. Try putting prints everywhere in os.py, until
you find the very last statement that is executed *BEFORE* this line appears:
importHook(imp, archive, locals, None) <-----here
In other words, let me know which line of os.py triggers this importHook.
> I noticed that in support\rthooks there is a file opengl.py and it is
> not compiled to a pyc, so it was never imported (does it mean that I
> forgot some switch?).
No that's fine: you should see "opengl" listed in ArchiveViewer in the first
screen (as soon as you start it on the executable).
--
Giovanni Bajo
Nothing of os.py gets executed (does it make sense?). I put a print
statement as the first line of os.py and even that doesn't appear.
No, it doesn't... at all!
Can you activate the Python verbose mode (add "('v', '', 'OPTION')" to TOC,
see the manual) and send me the output of your program with that?
--
Giovanni Bajo
voila:
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
import marshal # builtin
iu
import imp # builtin
import nt # builtin
import struct # builtin
importHook(encodings, __main__, locals, None)
importHook trying encodings in None
importHook(imp, archive, locals, None)
importHook trying imp in None
importHook done with imp archive None (case 2)
importHook(os, __main__, locals, None)
importHook trying os in None
importHook(imp, archive, locals, None)
importHook trying imp in None
importHook done with imp archive None (case 2)
importHook(os, __main__, locals, None)
importHook trying os in None
Traceback (most recent call last):
File "<string>", line 3, in ?
File "F:\pyinstaller\iu.py", line 334, in importHook
raise ImportError, "No module named %s" % fqname
ImportError: No module named encodings
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] zipimport
# cleanup[1] signal
# cleanup[1] exceptions
# cleanup[2] struct
# cleanup[2] iu
# cleanup[2] archive
# cleanup[2] imp
# cleanup[2] nt
# cleanup[2] marshal
# cleanup sys
# cleanup __builtin__
# cleanup ints: 19 unfreed ints in 2 out of 2 blocks
# cleanup floats
if python2.4 is installed then (all those "osn"s are prints I added to
os.py, so ignore them):
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# C:\Python24\Lib\warnings.pyc matches C:\Python24\Lib\warnings.py
import warnings # precompiled from C:\Python24\Lib\warnings.pyc
# C:\Python24\Lib\types.pyc matches C:\Python24\Lib\types.py
import types # precompiled from C:\Python24\Lib\types.pyc
# C:\Python24\Lib\linecache.pyc matches C:\Python24\Lib\linecache.py
import linecache # precompiled from C:\Python24\Lib\linecache.pyc
# C:\Python24\Lib\os.pyc matches C:\Python24\Lib\os.py
import os # precompiled from C:\Python24\Lib\os.pyc
os0
os1
os2
import nt # builtin
# C:\Python24\Lib\ntpath.pyc matches C:\Python24\Lib\ntpath.py
import ntpath # precompiled from C:\Python24\Lib\ntpath.pyc
# C:\Python24\Lib\stat.pyc matches C:\Python24\Lib\stat.py
import stat # precompiled from C:\Python24\Lib\stat.pyc
os3
os4
os5
os6
os7
# C:\Python24\Lib\UserDict.pyc matches C:\Python24\Lib\UserDict.py
import UserDict # precompiled from C:\Python24\Lib\UserDict.pyc
os8
os10
os11
os12
os13
os15
os16
# C:\Python24\Lib\copy_reg.pyc matches C:\Python24\Lib\copy_reg.py
import copy_reg # precompiled from C:\Python24\Lib\copy_reg.pyc
os17
os18
os19
os20
import marshal # builtin
iu
import imp # builtin
import struct # builtin
importHook(encodings, __main__, locals, None)
importHook trying encodings in None
importHook(imp, archive, locals, None)
importHook trying imp in None
importHook done with imp archive None (case 2)
importHook(os, __main__, locals, None)
importHook trying os in None
importHook done with os __main__ None (case 2)
importHook(imp, archive, locals, None)
importHook trying imp in None
importHook done with imp archive None (case 2)
importHook(os, __main__, locals, None)
importHook trying os in None
importHook done with os __main__ None (case 2)
importHook(zlib, archive, locals, None)
importHook trying zlib in None
importHook(os, __main__, locals, None)
importHook trying os in None
importHook done with os __main__ None (case 2)
import zlib # dynamically loaded from F:/pyinstaller/pok/distpok
\zlib.pyd
importHook done with zlib archive None (case 2)
importHook(codecs, encodings, locals, None)
importHook trying codecs in encodings
importHook trying codecs in None
importHook(__builtin__, codecs, locals, None)
importHook trying __builtin__ in None
importHook done with __builtin__ codecs None (case 2)
importHook(sys, codecs, locals, None)
importHook trying sys in None
importHook done with sys codecs None (case 2)
importHook(_codecs, codecs, locals, ('*',))
importHook trying _codecs in None
import _codecs # builtin
importHook done with _codecs codecs ('*',) (case 3)
importHook done with codecs encodings None (case 2)
importHook(exceptions, encodings, locals, None)
importHook trying exceptions in encodings
importHook trying exceptions in None
importHook done with exceptions encodings None (case 2)
importHook(types, encodings, locals, None)
importHook trying types in encodings
importHook trying types in None
importHook done with types encodings None (case 2)
importHook(aliases, encodings, locals, None)
importHook trying aliases in encodings
importHook done with aliases encodings None (case 2)
importHook done with encodings __main__ None (case 2)
importHook(OpenGL.GL, __main__, locals, None)
importHook trying OpenGL in None
importHook(string, OpenGL, locals, None)
importHook trying string in OpenGL
importHook trying string in None
importHook(re, string, locals, None)
importHook trying re in None
importHook(sre, re, locals, ('*',))
importHook trying sre in None
importHook(sys, sre, locals, None)
importHook trying sys in None
importHook done with sys sre None (case 2)
importHook(sre_compile, sre, locals, None)
importHook trying sre_compile in None
importHook(_sre, sre_compile, locals, None)
importHook trying _sre in None
import _sre # builtin
importHook done with _sre sre_compile None (case 2)
importHook(sys, sre_compile, locals, None)
importHook trying sys in None
importHook done with sys sre_compile None (case 2)
importHook(sre_constants, sre_compile, locals, ('*',))
importHook trying sre_constants in None
importHook done with sre_constants sre_compile ('*',) (case 3)
importHook done with sre_compile sre None (case 2)
importHook(sre_parse, sre, locals, None)
importHook trying sre_parse in None
importHook(sys, sre_parse, locals, None)
importHook trying sys in None
importHook done with sys sre_parse None (case 2)
importHook(sre_constants, sre_parse, locals, ('*',))
importHook trying sre_constants in None
importHook done with sre_constants sre_parse ('*',) (case 3)
importHook done with sre_parse sre None (case 2)
importHook(sre_parse, sre_compile, locals, None)
importHook trying sre_parse in None
importHook done with sre_parse sre_compile None (case 2)
importHook(copy_reg, sre, locals, None)
importHook trying copy_reg in None
importHook done with copy_reg sre None (case 2)
importHook done with sre re ('*',) (case 3)
importHook(sre, re, locals, ('__all__',))
importHook trying sre in None
importHook done with sre re ('__all__',) (case 3)
importHook done with re string None (case 2)
importHook(sre_parse, sre_compile, locals, None)
importHook trying sre_parse in None
importHook done with sre_parse sre_compile None (case 2)
importHook(strop, string, locals, ('maketrans', 'lowercase',
'uppercase', 'white
space'))
importHook trying strop in None
import strop # builtin
importHook done with strop string ('maketrans', 'lowercase',
'uppercase', 'white
space') (case 3)
importHook done with string OpenGL None (case 2)
importHook(os.path, OpenGL, locals, None)
importHook trying os in OpenGL
importHook trying os in None
importHook trying path in os
importHook done with os.path OpenGL None (case 2)
importHook(os, __main__, locals, None)
importHook trying os in None
importHook done with os __main__ None (case 2)
importHook(cStringIO, __main__, locals, None)
importHook trying cStringIO in None
import cStringIO # builtin
importHook done with cStringIO __main__ None (case 2)
importHook(GL.GL__init___, OpenGL, locals, ('__numeric_present__',
'__numeric_su
pport__'))
importHook trying GL in OpenGL
importHook(GL__init__, OpenGL.GL, locals, ('*',))
importHook trying GL__init__ in OpenGL.GL
importHook(GL__init___, OpenGL.GL.GL__init__, locals, None)
importHook trying GL__init___ in OpenGL.GL
importHook(_numpy, iu, locals, ['__doc__'])
importHook trying _numpy in None
importHook(_numpy, iu, locals, ['__doc__'])
importHook trying _numpy in None
import OpenGL.GL.GL__init___ # dynamically loaded from F:\pyinstaller
\pok
\distpok\OpenGL.GL.GL__init___.pyd
importHook done with GL__init___ OpenGL.GL.GL__init__ None (case 2)
importHook(operator, OpenGL.GL.GL__init__, locals,
('isSequenceType',))
importHook trying operator in OpenGL.GL
importHook trying operator in None
import operator # builtin
importHook done with operator OpenGL.GL.GL__init__ ('isSequenceType',)
(case 3)
importHook(Numeric, OpenGL.GL.GL__init__, locals, None)
importHook trying Numeric in OpenGL.GL
importHook trying Numeric in None
importHook done with GL__init__ OpenGL.GL ('*',) (case 3)
importHook trying GL__init___ in OpenGL.GL
importHook done with GL.GL__init___ OpenGL ('__numeric_present__',
'__numeric_su
pport__') (case 3)
importHook trying GL in OpenGL
importHook done with OpenGL.GL __main__ None (case 2)
hello
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] cStringIO
# cleanup[1] OpenGL
# cleanup[1] encodings
# cleanup[1] operator
# cleanup[1] OpenGL.GL
# cleanup[1] sre_constants
# cleanup[1] _codecs
# cleanup[1] zipimport
# cleanup[1] string
# cleanup[1] warnings
# cleanup[1] codecs
# cleanup[1] strop
# cleanup[1] sre
# cleanup[1] signal
# cleanup[1] OpenGL.GL.GL__init__
# cleanup[1] linecache
# cleanup[1] encodings.aliases
# cleanup[1] exceptions
# cleanup[1] sre_parse
# cleanup[1] sre_compile
# cleanup[1] _sre
# cleanup[1] types
# cleanup[1] re
# cleanup[1] OpenGL.GL.GL__init___
# cleanup[2] copy_reg
# cleanup[2] iu
# cleanup[2] archive
# cleanup[2] struct
# cleanup[2] imp
# cleanup[2] ntpath
# cleanup[2] nt
# cleanup[2] stat
# cleanup[2] UserDict
# cleanup[2] os.path
# cleanup[2] zlib
# cleanup[2] os
# cleanup[2] marshal
# cleanup sys
# cleanup __builtin__
# cleanup ints: 19 unfreed ints in 2 out of 10 blocks
# cleanup floats
Best regards
P.