How to import oauth2client on Google App Engine for Python and prevent "ImportError: No module named oauth2client.client"?

244 views
Skip to first unread message

Praxiteles via StackOverflow

unread,
May 16, 2017, 5:23:05 PM5/16/17
to google-appengin...@googlegroups.com

We are receiving an "ImportError: No module named OAuth2Client"

We have noticed scores of questions around this topic - many unanswered - and at least one answer that describes the solution to involve copying over files from Google's App Engine SDK.

This approach, however, seems tedious because all the dependencies are unclear. If we copy over oauth2client then run - the next error is another module that is missing. Fix that, then another module is missing. Etc. etc.

What seems ironic is that we can see all the files and modules needed listed from Google App Engine SDK right in PyCharm - but they seem inaccessible to the script.

Is there no better way to pull in virtually all the files that oauth2client needs for Python to work on App Engine?



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/44011776/how-to-import-oauth2client-on-google-app-engine-for-python-and-prevent-importer

Praxiteles via StackOverflow

unread,
May 16, 2017, 5:23:07 PM5/16/17
to google-appengin...@googlegroups.com

We found a quick way to solve this based on this documentation https://cloud.google.com/appengine/docs/python/tools/libraries27#vendoring and this SO answer.

  1. Create a new folder called "lib" in the same folder as your app.yaml file. (You can name it something else. Just use that name below.)

  2. Create an empty file called appengine_config.py in the same folder as your app.yaml file

  3. Add two lines to that appengine_config.py file:

    from google.appengine.ext import vendor vendor.add('lib')

  4. From terminal, navigate to the directory which contains that file and execute the following command:

    sudo pip install -t lib google-api-python-client

The import error will disappear and you will have all the sub-dependent modules as well.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/44011776/how-to-import-oauth2client-on-google-app-engine-for-python-and-prevent-importer/44011777#44011777
Reply all
Reply to author
Forward
0 new messages