python,

Resolve: "No module named oauth2client" in Python

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

Just like the previous post Resolve: No module named apiclient.discovery in Python this time being:

ModuleNotFoundError: No module named 'oauth2client'

Prerequisites

  • Python 3
  • pip

Solution

Step 1. cd to your Python project virtual environment directory.

Related: Create, manage and remove virtual environments in Python.

Step 2. Install the oauth2client module.

pip install --upgrade oauth2client

Note(s):

  • If the above command doesn’t work, try adding sudo in front.
  • Or, even replace pip with pip3.
  • oauth2client is long since deprecated, so consider replacing it with google-auth: pip install --upgrade google-auth.

The solution works too for the following errors as well:

ImportError: No module named oauth2client.service_account
ImportError: No module named oauth2client.client

Conclusion

Related: 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.