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
withpip3
.
Consider the following inline code as well:
from googleapiclient.discovery import build
Conclusion
Related posts:
- Resolve: No module named oauth2client in Python.
- Resolve: “No module named <insert-package-name-here>” in Python.
Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.