8

I am using Google's python API client, and one of the lines it wants you to use is:

from apiclient import discovery

When I run this it returns the error:

ImportError: cannot import name discovery

Note: the apiclient module is installed and up to date

Thanks guys

Bennett Brown
  • 4,981
  • 1
  • 26
  • 34
Lewys Gardner
  • 81
  • 1
  • 1
  • 6
  • Possible duplicate of [ImportError: No module named apiclient.discovery](https://stackoverflow.com/questions/18267749/importerror-no-module-named-apiclient-discovery) – fredtantini Aug 03 '17 at 07:00
  • @fredtantini but then I don't know how to implement that change into my code [this](https://developers.google.com/gmail/api/quickstart/python) is the whole google python api client code i used – Lewys Gardner Aug 03 '17 at 07:05

3 Answers3

9

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

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

See also: https://stackoverflow.com/a/23521799/1115187

maxkoryukov
  • 3,623
  • 5
  • 28
  • 48
Neeraj
  • 99
  • 3
9

At some point apiclient module name was changed. If you cannot import discovery from apiclient, then try:

from googleapiclient import discovery

Hope this helps.

  • 1
    actually `apiclient` is an alias for `googleapiclient` in the latest implementations. So, this answer didn't change anything for me. Until I used the other answer: https://stackoverflow.com/a/46064844/1115187 (which is downvoted without a real reason) – maxkoryukov Aug 01 '18 at 14:47
0

Try this

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

I got the answer from this link: python install module apiclient

Marvelous Ikechi
  • 1,649
  • 2
  • 13
  • 22