Question

[Solved] How to prevent “ImportError: No module named oauth2client.client” on Google App Engine?

We are receiving an error:

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 of copying over files from the Google 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 is 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 all the files that oauth2client needs for Python to work on App Engine?

Solution #1:

I have this problem and solved by installing oauth2client with pip3:

pip3 install --upgrade oauth2client 
Respondent: Praxiteles
Solution #2:

As per the google-api-python documentation, try this

pip install --upgrade google-api-python-client oauth2client
Respondent: Sadegh-khan
Solution #3:

The answer is to “vendor” in the file(s).

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.

Respondent: Sumithran
Solution #4:

Run this

sudo python -m pip install oauth2client

Respondent: Praxiteles
Solution #5:

Install WHL file

pip install oauth2client-4.1.3-py2.py3-none-any.whl
Respondent: Rahul Bhat
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy