Search code examples
google-app-enginepython-2.7modulegae-module

Google App Engine doesn't find local python module


For some reason when I uploaded my app engine project yesterday (before this, everything worked fine), it can't find one of my .py files/modules. My directory is as follows:

app_directory/
  gaesessions/
    __init__.py
  lib/
    httplib2/
      __init__.py
      other stuff
  app.yaml
  appengine_config.py
  index.yaml
  All other .py files/modules

For some reason I now get the following error:

import_string() failed for 'games.GetMyGames'. Possible reasons are:

- missing __init__.py in a package;
- package or module path not included in sys.path;
- duplicated package or module name taking precedence in sys.path;
- missing module, class, function or variable;

Original exception:

ImportError: cannot import name GameModel

Solution

  • I realized I had a circular import:

    in File1.py

    from File2 import class1
    

    and in File2.py

    from File1 import class3
    

    I changed to: in File1.py

    import File2
    

    and in File2.py

    import File1
    

    and I moved all of my class imports from File1 and File2 further down the files and this solved my issue. Hopefully this helps someone else.