Python-social, Django-nonrel, and GAE fighting over files, python-tk
Question: I'm trying to host a Django app on Google App Engine, so I'm using [Django
nonrel](https://github.com/django-nonrel/django) and following [these
instructions](http://www.allbuttonspressed.com/projects/djangoappengine). Now,
trying to get [Python social auth](https://github.com/omab/python-social-auth)
working on it, I'm running into two problems.

First, when working with code very similar to the [example Django
config](https://github.com/omab/python-social-
auth/tree/master/examples/django_example/example) from Python social, trying
to load a url from a running server, I get this:

    
    
    Traceback (most recent call last):
      File "/home/pablo/scripts/google_appengine/google/appengine/tools/dev_appserver.py", line 2989, in _HandleRequest
        self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
      File "/home/pablo/scripts/google_appengine/google/appengine/tools/dev_appserver.py", line 2832, in _Dispatch
        request_file = open(request_file_name, 'wb')
      File "/home/pablo/scripts/google_appengine/google/appengine/dev_appserver_import_hook.py", line 605, in __init__
        raise IOError('invalid mode: %s' % mode)
    IOError: invalid mode: wb
    

Somewhere, the app is trying to create local files, which App Engine doesn't
allow, but I'm confused because this is coming _from App Engine's code_. Does
anyone know where this might be coming from?

Secondly, when I try to access root on the server, I get the following error:

    
    
    ... [many lines elided]
      File "/home/pablo/scripts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 692, in Decorate
        return func(self, *args, **kwargs)
      File "/home/pablo/scripts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1642, in FindAndLoadModule
        description)
      File "/home/pablo/scripts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 692, in Decorate
        return func(self, *args, **kwargs)
      File "/home/pablo/scripts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1589, in LoadModuleRestricted
        description)
      File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module>
        raise ImportError, str(msg) + ', please install the python-tk package'
    ImportError: No module named _tkinter, please install the python-tk package
    

Somewhere, Django is trying to use `python-tk` for `Tkinter`, but as I
understand it, python-tk is a GUI library. How did it get here, and how can I
get rid of any code that needs it?

For reference, here's the function getting called for the domain I'm trying in
`urls.py` when accessing the running server (and getting these errors):

    
    
    def home(request):
        """Home view, displays login mechanism"""
        if request.user.is_authenticated():
            return redirect('done')
        return render_to_response('home.html', {
            'plus_id': getattr(settings, 'SOCIAL_AUTH_GOOGLE_PLUS_KEY', None)
        }, RequestContext(request))
    

Any help would be appreciated -- I'm pretty new to Django and Python, and I'd
love to move forward from this :D


Answer: Python on Google App Engine is behaving a bit different, as you already
realised with the local files. Another thing that needs a special treatment is
the 3rd party libraries that in order to make them available, they should be
[handled properly](http://stackoverflow.com/a/14851686/8418).

In many cases, even if you're going to include these libraries into your GAE
app, they might be using something that is not supported on the production so
the whole thing is not going to work.

