Python 3.4.0* - NameError: name '__file__' is not defined

Issue #61 resolved
Matteo Mattei
created an issue
cx-Freeze (4.3.2)
docutils (0.11)
Jinja2 (2.7.2)
MarkupSafe (0.18)
pip (1.5.2)
pycrypto (2.6.1)
Pygments (1.6)
PySide (1.2.1)
setuptools (2.1)
Sphinx (1.1.3)

Binary generation:

(3.4.0b3)matteo@myhost:~/pylibs/trunk$ cxfreeze test.py 
creating directory /home/spot/pylibs/trunk/dist                                                                                                                                                                
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/site-packages/cx_Freeze/bases/Console -> /home/spot/pylibs/trunk/dist/test                                                           
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/libpython3.4m.so.1.0 -> /home/spot/pylibs/trunk/dist/libpython3.4m.so.1.0                                                                      
writing zip file /home/spot/pylibs/trunk/dist/test                                                                                                                                                             

  Name                      File                                                                                                                                                                               
  ----                      ----                                                                                                                                                                               
P PySide                    /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/site-packages/PySide/__init__.py                                                                                 
m PySide.QtCore             /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/site-packages/PySide/QtCore.so                                                                                   
m PySide.QtGui              /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/site-packages/PySide/QtGui.so                                                                                    
m PySide.QtNetwork          /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/site-packages/PySide/QtNetwork.so                                                                                
m PySide._utils             /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/site-packages/PySide/_utils.py                                                                                   
m __main__                  test.py                                                                                                                                                                            
m _bootlocale                                                                                                                                                                                                  
m _bz2                      /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_bz2.cpython-34m.so                                                                                  
m _codecs                                                                                                                                                                                                      
m _codecs_cn                /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_codecs_cn.cpython-34m.so                                                                            
m _codecs_hk                /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_codecs_hk.cpython-34m.so                                                                            
m _codecs_iso2022           /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_codecs_iso2022.cpython-34m.so                                                                       
m _codecs_jp                /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_codecs_jp.cpython-34m.so                                                                            
m _codecs_kr                /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_codecs_kr.cpython-34m.so                                                                            
m _codecs_tw                /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_codecs_tw.cpython-34m.so                                                                            
m _collections                                                                                                                                                                                                 
m _collections_abc                                                                                                                                                                                             
m _ctypes                   /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_ctypes.cpython-34m.so                                                                               
m _datetime                 /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_datetime.cpython-34m.so                                                                             
m _dummy_thread                                                                                                                                                                                                
m _functools                                                                                                                                                                                                   
m _heapq                    /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_heapq.cpython-34m.so                                                                                
m _imp                                                                                                                                                                                                         
m _io                                                                                                                                                                                                          
m _locale                                                                                                                                                                                                      
m _multibytecodec           /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_multibytecodec.cpython-34m.so                                                                       
m _operator                                                                                                                                                                                                    
m _sre                                                                                                                                                                                                         
m _stat                                                                                                                                                                                                        
m _strptime                                                                                                                                                                                                    
m _struct                   /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_struct.cpython-34m.so                                                                               
m _thread                                                                                                                                                                                                      
m _threading_local                                                                                                                                                                                             
m _warnings                                                                                                                                                                                                    
m _weakref                                                                                                                                                                                                     
m _weakrefset                                                                                                                                                                                                  
m abc                                                                                                                                                                                                          
m argparse                                                                                                                                                                                                     
m array                     /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/array.cpython-34m.so                                                                                 
m atexit                                                                                                                                                                                                       
m base64                                                                                                                                                                                                       
m binascii                  /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/binascii.cpython-34m.so                                                                              
m builtins                                                                                                                                                                                                     
m bz2                                                                                                                                                                                                          
m calendar                                                                                                                                                                                                     
m codecs                                                                                                                                                                                                       
P collections                                                                                                                                                                                                  
m contextlib                                                                                                                                                                                                   
m copy                                                                                                                                                                                                         
m copyreg                                                                                                                                                                                                      
P ctypes                    /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/ctypes/__init__.py                                                                                               
m ctypes._endian            /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/ctypes/_endian.py                                                                                                
m ctypes.wintypes           /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/ctypes/wintypes.py                                                                                               
m cx_Freeze__init__         /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/site-packages/cx_Freeze/initscripts/Console3.py                                                                  
m datetime                                                                                                                                                                                                     
m dummy_threading                                                                                                                                                                                              
P encodings                                                                                                                                                                                                    
m encodings.aliases                                                                                                                                                                                            
m encodings.ascii                                                                                                                                                                                              
m encodings.base64_codec                                                                                                                                                                                       
m encodings.big5                                                                                                                                                                                               
m encodings.big5hkscs                                                                                                                                                                                          
m encodings.bz2_codec                                                                                                                                                                                          
m encodings.charmap                                                                                                                                                                                            
m encodings.cp037                                                                                                                                                                                              
m encodings.cp1006                                                                                                                                                                                             
m encodings.cp1026                                                                                                                                                                                             
m encodings.cp1125                                                                                                                                                                                             
m encodings.cp1140                                                                                                                                                                                             
m encodings.cp1250                                                                                                                                                                                             
m encodings.cp1251                                                                                                                                                                                             
m encodings.cp1252                                                                                                                                                                                             
m encodings.cp1253                                                                                                                                                                                             
m encodings.cp1254                                                                                                                                                                                             
m encodings.cp1255                                                                                                                                                                                             
m encodings.cp1256                                                                                                                                                                                             
m encodings.cp1257                                                                                                                                                                                             
m encodings.cp1258                                                                                                                                                                                             
m encodings.cp273                                                                                                                                                                                              
m encodings.cp424                                                                                                                                                                                              
m encodings.cp437                                                                                                                                                                                              
m encodings.cp500                                                                                                                                                                                              
m encodings.cp65001                                                                                                                                                                                            
m encodings.cp720                                                                                                                                                                                              
m encodings.cp737                                                                                                                                                                                              
m encodings.cp775                                                                                                                                                                                              
m encodings.cp850                                                                                                                                                                                              
m encodings.cp852                                                                                                                                                                                              
m encodings.cp855                                                                                                                                                                                              
m encodings.cp856                                                                                                                                                                                              
m encodings.cp857                                                                                                                                                                                              
m encodings.cp858                                                                                                                                                                                              
m encodings.cp860                                                                                                                                                                                              
m encodings.cp861                                                                                                                                                                                              
m encodings.cp862                                                                                                                                                                                              
m encodings.cp863                                                                                                                                                                                              
m encodings.cp864                                                                                                                                                                                              
m encodings.cp865                                                                                                                                                                                              
m encodings.cp866                                                                                                                                                                                              
m encodings.cp869                                                                                                                                                                                              
m encodings.cp874                                                                                                                                                                                              
m encodings.cp875                                                                                                                                                                                              
m encodings.cp932                                                                                                                                                                                              
m encodings.cp949                                                                                                                                                                                              
m encodings.cp950                                                                                                                                                                                              
m encodings.euc_jis_2004                                                                                                                                                                                       
m encodings.euc_jisx0213                                                                                                                                                                                       
m encodings.euc_jp                                                                                                                                                                                             
m encodings.euc_kr                                                                                                                                                                                             
m encodings.gb18030                                                                                                                                                                                            
m encodings.gb2312                                                                                                                                                                                             
m encodings.gbk                                                                                                                                                                                                
m encodings.hex_codec                                                                                                                                                                                          
m encodings.hp_roman8                                                                                                                                                                                          
m encodings.hz                                                                                                                                                                                                 
m encodings.idna                                                                                                                                                                                               
m encodings.iso2022_jp                                                                                                                                                                                         
m encodings.iso2022_jp_1                                                                                                                                                                                       
m encodings.iso2022_jp_2                                                                                                                                                                                       
m encodings.iso2022_jp_2004                                                                                                                                                                                    
m encodings.iso2022_jp_3                                                                                                                                                                                       
m encodings.iso2022_jp_ext                                                                                                                                                                                     
m encodings.iso2022_kr                                                                                                                                                                                         
m encodings.iso8859_1                                                                                                                                                                                          
m encodings.iso8859_10                                                                                                                                                                                         
m encodings.iso8859_11                                                                                                                                                                                         
m encodings.iso8859_13                                                                                                                                                                                         
m encodings.iso8859_14                                                                                                                                                                                         
m encodings.iso8859_15                                                                                                                                                                                         
m encodings.iso8859_16                                                                                                                                                                                         
m encodings.iso8859_2                                                                                                                                                                                          
m encodings.iso8859_3                                                                                                                                                                                          
m encodings.iso8859_4                                                                                                                                                                                          
m encodings.iso8859_5                                                                                                                                                                                          
m encodings.iso8859_6                                                                                                                                                                                          
m encodings.iso8859_7                                                                                                                                                                                          
m encodings.iso8859_8                                                                                                                                                                                          
m encodings.iso8859_9                                                                                                                                                                                          
m encodings.johab                                                                                                                                                                                              
m encodings.koi8_r                                                                                                                                                                                             
m encodings.koi8_u                                                                                                                                                                                             
m encodings.latin_1                                                                                                                                                                                            
m encodings.mac_arabic                                                                                                                                                                                         
m encodings.mac_centeuro                                                                                                                                                                                       
m encodings.mac_croatian                                                                                                                                                                                       
m encodings.mac_cyrillic                                                                                                                                                                                       
m encodings.mac_farsi                                                                                                                                                                                          
m encodings.mac_greek                                                                                                                                                                                          
m encodings.mac_iceland                                                                                                                                                                                        
m encodings.mac_latin2                                                                                                                                                                                         
m encodings.mac_roman                                                                                                                                                                                          
m encodings.mac_romanian                                                                                                                                                                                       
m encodings.mac_turkish                                                                                                                                                                                        
m encodings.mbcs                                                                                                                                                                                               
m encodings.palmos                                                                                                                                                                                             
m encodings.ptcp154                                                                                                                                                                                            
m encodings.punycode                                                                                                                                                                                           
m encodings.quopri_codec                                                                                                                                                                                       
m encodings.raw_unicode_escape                                                                                                                                                                                 
m encodings.rot_13                                                                                                                                                                                             
m encodings.shift_jis                                                                                                                                                                                          
m encodings.shift_jis_2004                                                                                                                                                                                     
m encodings.shift_jisx0213                                                                                                                                                                                     
m encodings.tis_620                                                                                                                                                                                            
m encodings.undefined                                                                                                                                                                                          
m encodings.unicode_escape                                                                                                                                                                                     
m encodings.unicode_internal                                                                                                                                                                                   
m encodings.utf_16                                                                                                                                                                                             
m encodings.utf_16_be                                                                                                                                                                                          
m encodings.utf_16_le                                                                                                                                                                                          
m encodings.utf_32                                                                                                                                                                                             
m encodings.utf_32_be                                                                                                                                                                                          
m encodings.utf_32_le                                                                                                                                                                                          
m encodings.utf_7                                                                                                                                                                                              
m encodings.utf_8                                                                                                                                                                                              
m encodings.utf_8_sig                                                                                                                                                                                          
m encodings.uu_codec                                                                                                                                                                                           
m encodings.zlib_codec                                                                                                                                                                                         
m errno                                                                                                                                                                                                        
m fnmatch                   /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/fnmatch.py                                                                                                       
m functools                                                                                                                                                                                                    
m gc                                                                                                                                                                                                           
m genericpath                                                                                                                                                                                                  
m gettext                                                                                                                                                                                                      
m heapq                                                                                                                                                                                                        
m imp                                                                                                                                                                                                          
P importlib                                                                                                                                                                                                    
m importlib._bootstrap                                                                                                                                                                                         
m importlib.machinery                                                                                                                                                                                          
m importlib.util                                                                                                                                                                                               
m io                                                                                                                                                                                                           
m itertools                                                                                                                                                                                                    
m keyword                                                                                                                                                                                                      
m linecache                                                                                                                                                                                                    
m locale                                                                                                                                                                                                       
m math                      /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/math.cpython-34m.so                                                                                  
m operator                                                                                                                                                                                                     
m optparse                                                                                                                                                                                                     
m os                                                                                                                                                                                                           
m posix                                                                                                                                                                                                        
m posixpath                                                                                                                                                                                                    
m pwd                                                                                                                                                                                                          
m quopri                                                                                                                                                                                                       
m re                                                                                                                                                                                                           
m reprlib                                                                                                                                                                                                      
m sre_compile                                                                                                                                                                                                  
m sre_constants                                                                                                                                                                                                
m sre_parse                                                                                                                                                                                                    
m stat                                                                                                                                                                                                         
m stringprep                                                                                                                                                                                                   
m struct                                                                                                                                                                                                       
m sys                                                                                                                                                                                                          
m textwrap                                                                                                                                                                                                     
m threading                                                                                                                                                                                                    
m time                      /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/time.cpython-34m.so                                                                                  
m token                                                                                                                                                                                                        
m tokenize                                                                                                                                                                                                     
m traceback                                                                                                                                                                                                    
m types                                                                                                                                                                                                        
m unicodedata               /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/unicodedata.cpython-34m.so                                                                           
m warnings                                                                                                                                                                                                     
m weakref                                                                                                                                                                                                      
m zipimport                                                                                                                                                                                                    
m zlib                      /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/zlib.cpython-34m.so                                                                                  

Missing modules:                                                                                                                                                                                               
? _dummy_threading imported from dummy_threading                                                                                                                                                               
? ce imported from os                                                                                                                                                                                          
? doctest imported from heapq                                                                                                                                                                                  
? getopt imported from base64, quopri                                                                                                                                                                          
? nt imported from os                                                                                                                                                                                          
? ntpath imported from os                                                                                                                                                                                      
? org.python.core imported from copy                                                                                                                                                                           
? os.path imported from os                                                                                                                                                                                     
? subprocess imported from os                                                                                                                                                                                  
This is not necessarily a problem - the modules may not be needed on this platform.                                                                                                                            

copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/site-packages/PySide/QtCore.so -> /home/spot/pylibs/trunk/dist/PySide.QtCore.so                                                      
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/site-packages/PySide/libpyside.cpython-34m.so.1.2 -> /home/spot/pylibs/trunk/dist/libpyside.cpython-34m.so.1.2                       
WARNING: cannot find libshiboken.cpython-34m.so.1.2                                                                                                                                                            
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/site-packages/PySide/libshiboken.cpython-34m.so.1.2 -> /home/spot/pylibs/trunk/dist/libshiboken.cpython-34m.so.1.2                   
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/site-packages/PySide/QtGui.so -> /home/spot/pylibs/trunk/dist/PySide.QtGui.so                                                        
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/site-packages/PySide/QtNetwork.so -> /home/spot/pylibs/trunk/dist/PySide.QtNetwork.so                                                
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_bz2.cpython-34m.so -> /home/spot/pylibs/trunk/dist/_bz2.cpython-34m.so                                                  
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_codecs_cn.cpython-34m.so -> /home/spot/pylibs/trunk/dist/_codecs_cn.cpython-34m.so                                      
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_codecs_hk.cpython-34m.so -> /home/spot/pylibs/trunk/dist/_codecs_hk.cpython-34m.so                                      
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_codecs_iso2022.cpython-34m.so -> /home/spot/pylibs/trunk/dist/_codecs_iso2022.cpython-34m.so                            
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_codecs_jp.cpython-34m.so -> /home/spot/pylibs/trunk/dist/_codecs_jp.cpython-34m.so                                      
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_codecs_kr.cpython-34m.so -> /home/spot/pylibs/trunk/dist/_codecs_kr.cpython-34m.so                                      
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_codecs_tw.cpython-34m.so -> /home/spot/pylibs/trunk/dist/_codecs_tw.cpython-34m.so                                      
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_ctypes.cpython-34m.so -> /home/spot/pylibs/trunk/dist/_ctypes.cpython-34m.so                                            
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_datetime.cpython-34m.so -> /home/spot/pylibs/trunk/dist/_datetime.cpython-34m.so                                        
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_heapq.cpython-34m.so -> /home/spot/pylibs/trunk/dist/_heapq.cpython-34m.so                                              
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_multibytecodec.cpython-34m.so -> /home/spot/pylibs/trunk/dist/_multibytecodec.cpython-34m.so                            
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/_struct.cpython-34m.so -> /home/spot/pylibs/trunk/dist/_struct.cpython-34m.so                                            
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/array.cpython-34m.so -> /home/spot/pylibs/trunk/dist/array.cpython-34m.so                                                
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/binascii.cpython-34m.so -> /home/spot/pylibs/trunk/dist/binascii.cpython-34m.so                                          
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/math.cpython-34m.so -> /home/spot/pylibs/trunk/dist/math.cpython-34m.so                                                  
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/time.cpython-34m.so -> /home/spot/pylibs/trunk/dist/time.cpython-34m.so                                                  
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/unicodedata.cpython-34m.so -> /home/spot/pylibs/trunk/dist/unicodedata.cpython-34m.so                                    
copying /home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/lib-dynload/zlib.cpython-34m.so -> /home/spot/pylibs/trunk/dist/zlib.cpython-34m.so                                                  
creating directory /home/spot/pylibs/trunk/dist/imageformats/                                                                                                                                                  
copying /usr/lib/qt4/plugins/imageformats/libqsvg.so -> /home/spot/pylibs/trunk/dist/imageformats/libqsvg.so                                                                                                   
copying /usr/lib/qt4/plugins/imageformats/libqjpeg.so -> /home/spot/pylibs/trunk/dist/imageformats/libqjpeg.so                                                                                                 
copying /usr/lib/qt4/plugins/imageformats/libqtiff.so -> /home/spot/pylibs/trunk/dist/imageformats/libqtiff.so                                                                                                 
copying /usr/lib/qt4/plugins/imageformats/libqmng.so -> /home/spot/pylibs/trunk/dist/imageformats/libqmng.so                                                                                                   
copying /usr/lib/qt4/plugins/imageformats/libqgif.so -> /home/spot/pylibs/trunk/dist/imageformats/libqgif.so                                                                                                   
copying /usr/lib/qt4/plugins/imageformats/libqico.so -> /home/spot/pylibs/trunk/dist/imageformats/libqico.so                                                                                                   
copying /usr/lib/kde4/plugins/imageformats/kimg_pcx.so -> /home/spot/pylibs/trunk/dist/imageformats/kimg_pcx.so                                                                                                
copying /usr/lib/kde4/plugins/imageformats/kimg_psd.so -> /home/spot/pylibs/trunk/dist/imageformats/kimg_psd.so                                                                                                
copying /usr/lib/kde4/plugins/imageformats/kimg_eps.so -> /home/spot/pylibs/trunk/dist/imageformats/kimg_eps.so                                                                                                
copying /usr/lib/kde4/plugins/imageformats/kimg_xview.so -> /home/spot/pylibs/trunk/dist/imageformats/kimg_xview.so                                                                                            
copying /usr/lib/kde4/plugins/imageformats/kimg_tga.so -> /home/spot/pylibs/trunk/dist/imageformats/kimg_tga.so                                                                                                
copying /usr/lib/kde4/plugins/imageformats/kimg_dds.so -> /home/spot/pylibs/trunk/dist/imageformats/kimg_dds.so                                                                                                
copying /usr/lib/kde4/plugins/imageformats/kimg_rgb.so -> /home/spot/pylibs/trunk/dist/imageformats/kimg_rgb.so                                                                                                
copying /usr/lib/kde4/plugins/imageformats/kimg_xcf.so -> /home/spot/pylibs/trunk/dist/imageformats/kimg_xcf.so                                                                                                
copying /usr/lib/kde4/plugins/imageformats/kimg_exr.so -> /home/spot/pylibs/trunk/dist/imageformats/kimg_exr.so                                                                                                
copying /usr/lib/kde4/plugins/imageformats/kimg_jp2.so -> /home/spot/pylibs/trunk/dist/imageformats/kimg_jp2.so  

Then when I execute the binary I have the following error:

(3.4.0b3)matteo@myhost:~/pylibs/trunk$ ./dist/test 
Traceback (most recent call last):                                                                                                                                                                             
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/site-packages/cx_Freeze/initscripts/Console3.py", line 27, in <module>                                                               
    exec(code, m.__dict__)                                                                                                                                                                                     
  File "test.py", line 3, in <module>                                                                                                                                                                          
    import sys, time                                                                                                                                                                                           
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 2213, in _find_and_load                                                                               
    return _find_and_load_unlocked(name, import_)                                                                                                                                                              
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 2202, in _find_and_load_unlocked                                                                      
    module = _SpecMethods(spec)._load_unlocked()                                                                                                                                                               
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 1190, in _load_unlocked                                                                               
    return self._load_backward_compatible()                                                                                                                                                                    
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 1160, in _load_backward_compatible                                                                    
    spec.loader.load_module(spec.name)                                                                                                                                                                         
  File "ExtensionLoader_time.py", line 22, in <module>                                                                                                                                                         
  File "ExtensionLoader_time.py", line 3, in __bootstrap__                                                                                                                                                     
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 2213, in _find_and_load                                                                               
    return _find_and_load_unlocked(name, import_)                                                                                                                                                              
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 2202, in _find_and_load_unlocked                                                                      
    module = _SpecMethods(spec)._load_unlocked()                                                                                                                                                               
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 1199, in _load_unlocked                                                                               
    self._exec(module)                                                                                                                                                                                         
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 1128, in _exec                                                                                        
    self.spec.loader.exec_module(module)                                                                                                                                                                       
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 1335, in exec_module                                                                                  
    exec(code, module.__dict__)                                                                                                                                                                                
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/imp.py", line 19, in <module>                                                                                                        
    from importlib._bootstrap import SourcelessFileLoader, _ERR_MSG, _SpecMethods                                                                                                                              
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 2213, in _find_and_load                                                                               
    return _find_and_load_unlocked(name, import_)                                                                                                                                                              
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 2188, in _find_and_load_unlocked                                                                      
    _call_with_frames_removed(import_, parent)                                                                                                                                                                 
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 321, in _call_with_frames_removed                                                                     
    return f(*args, **kwds)                                                                                                                                                                                    
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 2213, in _find_and_load                                                                               
    return _find_and_load_unlocked(name, import_)                                                                                                                                                              
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 2202, in _find_and_load_unlocked                                                                      
    module = _SpecMethods(spec)._load_unlocked()                                                                                                                                                               
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 1199, in _load_unlocked                                                                               
    self._exec(module)                                                                                                                                                                                         
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 1128, in _exec                                                                                        
    self.spec.loader.exec_module(module)                                                                                                                                                                       
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/_bootstrap.py", line 1335, in exec_module                                                                                  
    exec(code, module.__dict__)                                                                                                                                                                                
  File "/home/spot/pylibs/trunk/python/linux/python-3.4.0b3/lib/python3.4/importlib/__init__.py", line 25, in <module>                                                                                         
    _bootstrap.__file__ = __file__.replace('__init__.py', '_bootstrap.py')                                                                                                                                     
NameError: name '__file__' is not defined 

Same error on Windows using the same python and cx_freeze versions.
If I execute the test.py script manually it works fine without any type of error.

Comments (26)

  1. Jurko Gospodnetić

    Simpler way to reproduce the same error - just try to freeze the following source code

    print("Hello world")
    import asyncio
    import sys
    print(sys.version_info)
    

    In fact I think it's just import asyncio that is necessary but the rest makes the script more test/user-friendly. 😄

    Here's a related setup.py script you can use:

    from cx_Freeze import setup, Executable
    setup(name="HelloWorld",
          version="0.1",
          description="HelloWorld",
          executables=[Executable("hello_world.py", base="Console")])
    

    Hope this helps.

    Best regards,
    Jurko Gospodnetić

  2. Thomas Kluyver

    Reducing the example further: replace asyncio with importlib (which asyncio actually imports, via inspect):

    $ ./build/exe.linux-x86_64-3.4/hello_world 
    Hello world
    Traceback (most recent call last):
      File "/home/takluyver/.local/lib/python3.4/site-packages/cx_Freeze-4.3.2-py3.4-linux-x86_64.egg/cx_Freeze/initscripts/Console3.py", line 27, in <module>
        exec(code, m.__dict__)
      File "hello_world.py", line 2, in <module>
        import importlib
      File "/usr/lib/python3.4/importlib/_bootstrap.py", line 2214, in _find_and_load
        return _find_and_load_unlocked(name, import_)
      File "/usr/lib/python3.4/importlib/_bootstrap.py", line 2203, in _find_and_load_unlocked
        module = _SpecMethods(spec)._load_unlocked()
      File "/usr/lib/python3.4/importlib/_bootstrap.py", line 1200, in _load_unlocked
        self._exec(module)
      File "/usr/lib/python3.4/importlib/_bootstrap.py", line 1129, in _exec
        self.spec.loader.exec_module(module)
      File "/usr/lib/python3.4/importlib/_bootstrap.py", line 1336, in exec_module
        exec(code, module.__dict__)
      File "/usr/lib/python3.4/importlib/__init__.py", line 25, in <module>
        _bootstrap.__file__ = __file__.replace('__init__.py', '_bootstrap.py')
    NameError: name '__file__' is not defined
    

    I wouldn't expect __file__ to be defined for modules loaded from a zip file. The odd thing is, the same line is there in Python 3.3, and it doesn't fail.

  3. Anthony Tuininga repo owner

    In Python 3.3 the value of

    __file__
    

    is <frozen> which is clearly different from what Python 3.4 is doing. Any thoughts on where to go from here? Do we need to push a bug fix to the Python core to do a try....except clause there?

  4. Nick Coghlan

    Could you check what happens when freezing a dummy __init__.py file that just contains __file__? My current theory involves something weird going on with freezing packages, and if that theory is correct, then such a package should throw NameError when imported in place of importlib or asyncio in the example.

    That is:

    /dummy
        /__init__.py
    

    And then "import dummy" from the demo script.

  5. Jurko Gospodnetić

    If you meant want the main frozen program script file to import a file containing just the 4 bites - file - then the output is this:

    D:\Workspace>build\exe.win-amd64-3.4\hello_world.exe
    Hello world
    Traceback (most recent call last):
      File "C:\Program Files\Python\Python34rc3\lib\site-packages\cx_freeze-4.3.2-py3.4-win-amd64.egg\cx_Freeze\initscripts\Console.py", line 27, in <module>
        exec(code, m.__dict__)
      File "hello_world.py", line 2, in <module>
        import gugu
      File "C:\Program Files\Python\Python34rc3\lib\importlib\_bootstrap.py", line 2214, in _find_and_load
        return _find_and_load_unlocked(name, import_)
      File "C:\Program Files\Python\Python34rc3\lib\importlib\_bootstrap.py", line 2203, in _find_and_load_unlocked
        module = _SpecMethods(spec)._load_unlocked()
      File "C:\Program Files\Python\Python34rc3\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
        return self._load_backward_compatible()
      File "C:\Program Files\Python\Python34rc3\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
        spec.loader.load_module(spec.name)
      File "C:\Users\Jurko\hhh\gugu\__init__.py", line 1, in <module>
        file
    NameError: name 'file' is not defined
    

    But that might not be quite what Python calls a frozen module. Its content is read from the library.zip file constructed by cx_Freeze, while the importlib\__init__.py lib does not get stored there.

    I'll take a look at the cx_Freeze source to see how the importlib\__init__py module gets packaged.

  6. Nick Coghlan

    Oops, forgot about the bad interaction between dunder names and the comment formatting - fixed the proposed modification to hopefully be clearer.

    Actually about to head to bed here (it's rather late in BNE), otherwise I would just try it myself :)

  7. Jurko Gospodnetić

    Ok, importing a package gugu containing a single file __init__.py whose only content are 8 bytes - __file__ works fine.

    But as I said above, I am not really sure that package actually gets 'frozen' as referred to in Python documentation. I can see that its gugu/__init__.pyc file gets stored in a library.zip archive constructed by cx_Freeze while importlib/__init__.pyc does not. I'll take a look at the cx_Freeze sources to see where the difference is and let you know if I find anything.

    P.S. Don't know what or where 'BNE' is - Brisbane, Australia? :-)

  8. Jurko Gospodnetić

    Ok, I think I managed to get such a module 'frozen' as referred to in Python documentation. I placed it under a folder on PYTHONPATH (under Python 3.4 site-packages) and modified cx_Freeze's cx_Freeze/finder.py module so that its ModuleFinder._AddBaseModules() method does self.IncludeModule("gugu") just after it imports importlib.

    That resulted in the frozen executable's library.zip file not containing the gugu/__init__.pyc file and displaying the following output when started:

    D:\Workspace>build\exe.win-amd64-3.4\hello_world.exe
    Hello world
    Traceback (most recent call last):
      File "C:\Program Files\Python\Python34rc3\lib\site-packages\cx_freeze-4.3.2-py3.4-win-amd64.egg\cx_Freeze\initscripts\Console.py", line 27, in <module>
        exec(code, m.__dict__)
      File "hello_world.py", line 2, in <module>
        import gugu
      File "C:\Program Files\Python\Python34rc3\lib\importlib\_bootstrap.py", line 2214, in _find_and_load
        return _find_and_load_unlocked(name, import_)
      File "C:\Program Files\Python\Python34rc3\lib\importlib\_bootstrap.py", line 2203, in _find_and_load_unlocked
        module = _SpecMethods(spec)._load_unlocked()
      File "C:\Program Files\Python\Python34rc3\lib\importlib\_bootstrap.py", line 1200, in _load_unlocked
        self._exec(module)
      File "C:\Program Files\Python\Python34rc3\lib\importlib\_bootstrap.py", line 1129, in _exec
        self.spec.loader.exec_module(module)
      File "C:\Program Files\Python\Python34rc3\lib\importlib\_bootstrap.py", line 1336, in exec_module
        exec(code, module.__dict__)
      File "C:\Program Files\Python\Python34rc3\lib\site-packages\gugu\__init__.py", line 1, in <module>
        __file__
    NameError: name '__file__' is not defined
    

    Hope this helps.

    Best regards,
    Jurko Gospodnetić

  9. Thomas Kluyver

    It now looks like it might get fixed in Python after all, so I'm holding off on fixing it in cx_Freeze. I'm not sure that we should be freezing importlib into the bases anyway, but it will be needed by practically all non-trivial applications, because we use it (via imp) to load extension modules.

  10. Jurko Gospodnetić

    Note that it will most likely not be fixed for Python 3.4.0. I'm guessing that an actual fix will be released only in Python 3.4.1, so you might consider adding a different 3.4.0 specific workaround.

    Perhaps something as described in the Python issue - manually adding __file__ = 'something' in the importlib/__init__.py module before freezing it (not sure personally of all the details and if and how this can be done).

  11. Jurko Gospodnetić

    Could you take a look at my comment in that pull request? It was never addressed... the patch fixes the original issue but leaves some other newly opened ones.

    I think Anthony overlooked it when doing the merge. 😢

  12. Log in to comment