Errors and solutions

ModuleNotFoundError: No module named ‘google’

Traceback (most recent call last):
  File "speech_quickstart_beta.py", line 28, in <module>
    from google.cloud import speech_v1p1beta1
ModuleNotFoundError: No module named 'google'

Solution 1

The Google Cloud SDK may not be installed correctly.

With the virtual environment activated run:

pip install google-cloud   

Solution 2

The Google Cloud SDK may not be installed

  1. Download the latest SDK, as documented here
  2. Extract the contents of the file to any location on your file system
  3. Run gcloud init to initialize the SDK
./google-cloud-sdk/bin/gcloud init

ImportError: cannot import name ‘speech_v1p1beta1’

This means that the Python client libraries are not installed.

ImportError: cannot import name 'speech_v1p1beta1' from 'google.cloud' (unknown location)

Solution 1

pip install --upgrade google-cloud-speech

You might need to use pip3 instead of pip

Error no such file or directory

ERROR: (gcloud.auth.activate-service-account) Unable to read file [apiCredentials.json]: [Errno 2] No such file or directory: 'apiCredentials.json'

Solution 1

  1. Ensure apiCredentials.json exists
ls apiCredentials.json

This means it either does not exist or is not in the current path

ls: cannot access 'apiCredentials.json': No such file or directory

Consult the Create a Service Account and API Keys lesson for the creation of apiCredentials.json and set up the environment variables as mentioned in Setting Up the Environment lesson.

Solution 2

  1. Once you have confirmed the apiCredentials.json file exists using solution 1, set the environment variable
export GOOGLE_APPLICATION_CREDENTIALS="apiCredentials.json"

Other errors

Consult one or more of these resources:

Get hands-on with 1200+ tech skills courses.