python,

Resolve: "No module named apiclient.discovery" in Python

Nov 20, 2022 · 1 min read · Post a comment

A few days ago I was getting the following error: ImportError: No module named apiclient.discovery.

This was the output from docker logs python-api command as my Python Docker container was exiting right after docker compose up -d. It turns out it was an old issue, so I had to do my “research” as every other computer engineer out there.

Prerequisites

  • Python 3
  • pip

Solution

Run the following command:

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

Note(s):

  • If the above command doesn’t work, try adding sudo in front.
  • Or, even replace pip with pip3.

Consider the following inline code as well:

from googleapiclient.discovery import build

Conclusion

Related posts:

Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.