Reputation: 888
I would like to use Google Cloud Storage Client Library Functions.
For that I have to import the cloudstorag
. To get the cloudstorage
I download Google Cloud Storage client library.
I try to import cloudstorage using python -c "import cloudstorage"
. I get the following error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "cloudstorage/__init__.py", line 20, in <module>
from .api_utils import RetryParams
File "cloudstorage/api_utils.py", line 45, in <module>
from google.appengine.api import app_identity
ImportError: No module named google.appengine.api
Am I missing something?
Upvotes: 3
Views: 8332
Reputation: 11
You can add this lines, which will add the path of the sdk tools:
import pkgutil
import google
google.__path__ = pkgutil.extend_path(google.__path__, google.__name__)
For unittesting, it could be useful to run in standalone mode.
Upvotes: 1
Reputation: 39814
When you execute python -c "import cloudstorage"
you're attempting to run a standalone application. But the GCS library you're trying to use is for a (standard environment) GAE application, which cannot be executed as a standalone app, it needs to run in a GAE sandbox (locally that's dev_appserver.py
). See GAE: AssertionError: No api proxy found for service "datastore_v3".
And the library needs to be installed inside your GAE app, see Copying a third-party library.
If you're not developing a standard env GAE app and indeed you want to write a standalone one, you're not looking at the right documentation. You need to use a different library than the GAE-specific one(s). See Cloud Storage Client Libraries
Upvotes: 5
Reputation: 5940
Looks like gcloud is not installed on your system.
pip install --upgrade gcloud
pip install --upgrade google-api-python-client
Upvotes: 0