简体   繁体   中英

Python-social, Django-nonrel, and GAE fighting over files, python-tk

I'm trying to host a Django app on Google App Engine, so I'm using Django nonrel and following these instructions . Now, trying to get Python social auth working on it, I'm running into two problems.

First, when working with code very similar to the example Django config 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

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM