Why Is My Python App Engine App Using the Translate API Getting an Error of Importerror: No Module Named APIclient.Discovery

Why is my Python App Engine app using the Translate API getting an error of ImportError: No module named apiclient.discovery?

You should be able to get these dependencies with this simple install:

sudo pip install --upgrade google-api-python-client

This is described on the quick start page for python.

from apiclient.discovery import build ModuleNotFoundError: No module named 'apiclient.discovery'

Nevermind I fixed the issue by switching apiclient with googleapiclient

python install module apiclient

Try this:

sudo pip install --upgrade google-api-python-client

OR

Make sure you only have google-api-python-client installed. If you have apiclient installed, it will cause a collision. So, run the following:

pip install --force-reinstall google-api-python-client

Answer Source

How to prevent ImportError: No module named oauth2client.client on Google App Engine?

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.



Related Topics



Leave a reply



Submit