GAE doesn't import gflags
Asked Answered
N

2

6

I'm trying to get oauth to work on Google App Engine (GAE), but I'm unable to import the OAuth2Decorator, because it tries to import gflags and fails.

In command line I've ran help('modules') and gflags is listed, and I've ran import os + import gflags + print os.path.dirname(gflags.__file__) and received /Library/Python/2.7/site-packages/python_gflags-2.0-py2.7.egg.

In GAE Dev Console I've ran:

import sys
import os

try:
  import webapp2
  import httplib2
  from oauth2client.appengine import OAuth2Decorator 

except ImportError, e:
  print("The import failed!")
  print(e)

and received:

The import failed!
No module named gflags

gflags is imported by from oauth2client.appengine import OAuth2Decorator, but GAE fails to import gflags every time I run the code.

I'm not sure it makes a difference, but I'm running Mac OS 10.7.5 and python 2.7.1

Neile answered 25/11, 2012 at 3:7 Comment(0)
F
6

Sorry, I just recently updated the installation instructions with App Engine specific instructions:

https://developers.google.com/api-client-library/python/start/installation

There is a download specifically for App Engine that contains all the client library code and dependencies, just unzip that file into your project and you should be good to go.

Fictile answered 26/11, 2012 at 1:12 Comment(2)
I'm not using appengine and just need oauth client library on my server. I'm still getting this error after following the non-appengine specific instructions on the page. This is a bit frustrating.Swarth
This reoccured for me.Mikkel
O
2

You'll need to add the required library files to your App Engine project. From the client library docs, once you've installed the client library run:

$ enable-app-engine-project your_app_directory
Organdy answered 25/11, 2012 at 4:56 Comment(1)
I ran that command and I gave me an error saying oauth2client already existed in the directory, which it did because I manually put it there, so I deleted it and reran the command. The problem is that it only copied the __init__.py file into the new oauth2client directory, and not the rest of the oauth2client files, such as the app engine.py file. I tried reinstalling oauth2client but that didn't work, so I've just manually replaced the folder. Should I have to manually add the files or should it copy all of them over?Neile

© 2022 - 2024 — McMap. All rights reserved.