[Python] ModuleNotFoundError: No module named 'google' in WSL

Discussão em 'Python' iniciado por Stack, Setembro 5, 2025.

  1. Stack

    Stack Membro Participativo

    I was trying to use google cloud storage in a python virtual environment. I tried installing google-cloud-storage and whenever I run the code I always get the error ModuleNotFoundError: No module named 'google'

    I tried reinstalling the packages and using new python virtual environment but nothing is working.

    FYI: I am using WSL2

    from google.cloud import storage
    import os

    class GoogleCloudStorage:

    def store(self, backup_path, config):
    try:
    client = storage.Client(project=config.get('project'))
    bucket_name = config.get('bucket')
    path = config.get('path')

    if config.get('credentials'):
    os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = config.get('credentials')


    bucket = client.bucket(bucket_name)
    blob = bucket.blob(f"{path}/{backup_path.split('/')[-1]}")

    blob.upload_from_filename(backup_path)
    print(f"Backup {backup_path} uploaded to {bucket_name}/{path}/")
    except Exception as e:
    print(f"Failed to store backup: {e}")
    raise e

    Continue reading...

Compartilhe esta Página