Q:

Installing google api client to send emails from python

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!

A:

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

