Reputation: 425
2021-12-23T17:33:55.099Zpython-api-request cannot import name 'storage' from 'google.cloud' (unknown location)
cannot import name 'storage' from 'google.cloud' (unknown location)
Why am I getting this error? This is my requirements.txt
# Function dependencies, for example:
# package>=version
pandas
requests
datetime
google-cloud
And my main.py
import requests
import pandas as pd
import datetime
import os
from google.cloud import storage
from dotenv import load_dotenv
It works completely fine in my local machine terminal when I execute my code but why is Cloud Function complaining about my user code?
Upvotes: 1
Views: 6174
Reputation: 57
what worked for me is this:
1 If the package is already installed, you can try upgrading it to the latest version:
pip install --upgrade google-cloud-storage
2 If the issue still persists, you can also try uninstalling and then reinstalling the package:
pip uninstall google-cloud-storage
pip install google-cloud-storage
3 After you have installed or upgraded the package, you can try importing storage from google.cloud again.
Upvotes: 1
Reputation: 4489
Your requirements.txt should have google-cloud-storage
rather than just google-cloud
. The base doesn't contain the storage package, they are each separately installed but then called from the base package.
Upvotes: 6