Python 3.3 cx_freeze weird error: 'NoneType' object has no attribute 'path'
Question: So, here's my problem.

I'm making a game in Pygame and Python 3.3, using Ubuntu 12.10. Fine. I'm
gonna bundle a bunch of Python scripts into one executable, then distribute
it. Also fine. I'm going with cx_freeze, because since I'm using Python 3 I
have no other options.

This is where my problem comes in. I've Googled around, but haven't seen
anything like it. My `setup.py` is as follows:

    
    
    from cx_Freeze import setup, Executable
    import sys
    
    includes = ['sys', 'pygame.display', 'pygame.event', 'pygame.mixer', 'core', 'game']
    
    build_options = {
                     'optimize' : 2,
                     'compressed': True,
                     'packages': ['pygame', 'core', 'game'],
                     'includes': includes,
                     'path': sys.path + ['core', 'game'],
                     }
    
    executable = Executable('__init__.py',
                            copyDependentFiles=True,
                            targetDir='dist',
                            )
    
    setup(name='Invasodado',
          version='0.8',
          description='wowza!',
          options = {'build_exe': build_options},
          executables=[executable])
    

My `__init__.py` is as follows:

    
    
    from sys import argv
    
    import pygame.display
    import pygame.event
    import pygame.mixer
    
    pygame.mixer.init()
    pygame.display.init()
    pygame.font.init()
    
    from core import gsm
    
    #Omitted for brevity
    

The rest of my code (including the full `__init__.py`) can be found at
<https://github.com/CorundumGames/Invasodado>, in case it's relevant.

I get a long-ass stack trace, which can be found here
<http://pastebin.com/Aej05wGE> . The last 10 lines of it is this;

    
    
      File "/usr/local/lib/python3.3/dist-packages/cx_Freeze/finder.py", line 421, in _RunHook
        method(self, *args)
      File "/usr/local/lib/python3.3/dist-packages/cx_Freeze/hooks.py", line 454, in load_scipy
        finder.IncludePackage("scipy.lib")
      File "/usr/local/lib/python3.3/dist-packages/cx_Freeze/finder.py", line 536, in IncludePackage
        self._ImportAllSubModules(module, deferredImports)
      File "/usr/local/lib/python3.3/dist-packages/cx_Freeze/finder.py", line 211, in _ImportAllSubModules
        recursive)
      File "/usr/local/lib/python3.3/dist-packages/cx_Freeze/finder.py", line 209, in _ImportAllSubModules
        if subModule.path and recursive:
    AttributeError: 'NoneType' object has no attribute 'path'
    

In case it's relevant, I'm using Pydev and Eclipse. Now, the last line stands
out because Googling it reveals nothing. I have no idea where `subModule`
could have become `None`, and I can't easily check because cx_freeze has shit
documentation.

I've never really used cx_freeze or distutils before, so I don't know what the
hell I'm doing! Any help would be greatly appreciated.


Answer: Having dug into this, it's a bug in cx_Freeze, that can only hit when you have
more than one Python version since [PEP
3149](http://docs.python.org/3/whatsnew/3.2.html#pep-3149-abi-version-tagged-
so-files) installed - i.e. it wouldn't have come up before 3.3.

I've filed a bug report for it:
<https://bitbucket.org/anthony_tuininga/cx_freeze/issue/22/error-when-
scanning-for-modules-with-a>

In the mean time, you can probably avoid the problem by using Python 3.2 for
now, because that's the default in Ubuntu 12.10. Python 3.3 will be the
default in 13.04.

