No module named ‘google.cloud’ in Python

Are you getting the error “modulenotfounderror: no module named ‘google.cloud’ in Python“? Yes, you have come to the right place. Today I will show how to solve this error.

This error occurs when you don’t have the specific ‘google.cloud‘ module installed in your system.

[Fixed]: ModuleNotFoundError: No module named ‘skimage’ in Python

[Fixed]: No module named ‘google.cloud’ in Python

You can solve this error by installing the specific version of google.cloud that you are using in your code. for example, “pip install google-cloud-speech” if you are using ‘speech‘ or “pip install google-cloud-storage” if you are using ‘storage’ in your code.

Open your terminal and install the specific module that you are importing into your program.

# To install speech
pip install google-cloud-speech

# To install storage
pip install google-cloud-storage

# To install bigquery
pip install google-cloud-bigquery

# To install texttospeech
pip install google-cloud-texttospeech

After installing the module, e.g., “google-cloud-speech,” we can import it as:

from google.cloud import speech
print(dir(speech))

This print (print(dir(speech))) statement will print all directories in the speech module.

If you are outside a virtual environment, you might have to use pip3 instead of pip.

# To installs storage
pip3 install google-cloud-storage

# If you get permissions error you can use this command
sudo pip3 install google-cloud-storage

If you don’t have pip in your PATH environment variable, you can replace “pip” with “python -m pip.”

# If you don't have pip in your PATH environment variable
python -m pip install google-cloud-speech

# For python 3 (could also be pip3.10 depending on your version)
python3 -m pip install google-cloud-speech

The Python error “No module named ‘google.cloud’ in Python” can occur for multiple reasons:

  1. Not having google.cloud package installed. If you have not installed the google.cloud package then you can install it with this command “pip install google.cloud.*”.
  2. Installing the google.cloud package in a different python version than you are using.
  3. Installing the package in the global environment when you are using the virtual environment.
  4. You are using the incorrect version of python on your IDE. (e.g. VS Code)
  5. Using the file name “google.cloud.*.py“. If you are using a name like this google.cloud.*.py then consider it change to something else.
  6. Declaring a variable with the name “google.cloud.*“. If you have a variable google.cloudchange.* change its name to something else.

Conclusion on No module named ‘google.cloud’ in Python

Programmers, we discussed how we can solve this error “modulenotfounderror: no module named ‘google.cloud’ in Python“. If you are still facing the error please let us know in the comments section. You can solve this error by installing the specific version of google.cloud that you are using in your code.

Leave a Reply