1

I'm trying to learn how to send emails in python using the Gmail API.

One of the first lines in my script:

from googleapiclient.discovery import build

gives me the error:

No module named googleapiclient.discovery

I am trying to install googleapiclient by doing:

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

which seems to do all the right things until the end when it says:

Installing collected packages: httplib2, uritemplate, rsa, cachetools, pyasn1-modules, google-auth, google-auth-httplib2, google-api-python-client
  Found existing installation: httplib2 0.9.1
Cannot uninstall 'httplib2'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

I wasn't sure if this message would stop thing from working, but I am still getting the message:

No module named googleapiclient.discovery

when I try to run my code. Any suggestions gratefully received!

6
  • 1
    Try pip uninstall httplib2 and run this sudo pip install --upgrade google-api-python-client again or check if the package is installed already pip show google-api-python-client. Commented Dec 25, 2018 at 12:03
  • I get the same message when I try to uninstall: Cannot uninstall 'httplib2'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. Commented Dec 25, 2018 at 12:09
  • 1
    I suggest you to try installing the packages using pip install --user google-api-python-client after uninstalling it using pip uninstall google-api-python-client. Commented Dec 25, 2018 at 12:11
  • 2
    If that didn't solve your problem, please do check this page. It is dealing with similar issue. Commented Dec 25, 2018 at 12:15
  • 1
    Great to know that i did solve your problems. I will post this as answer. Commented Dec 25, 2018 at 12:15

1 Answer 1

1

The OP is facing a similar issue mentioned here.

Using the --user option to install the package will solve this issue in most cases. Before installing the package. We must uninstall google-api-python-client first.

pip uninstall google-api-python-client

Now install the package using the --user option.

pip install --user google-api-python-client
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.