I am trying to generate signUrl in python 2.7 using v4 signing process as given here below is the code given on the link:
def generate_singed_url(bucket_name, blob_name):
"""Generates a v4 signed URL for downloading a blob.
Note that this method requires a service account key file. You can not use
this if you are using Application Default Credentials from Google Compute
Engine or from the Google Cloud SDK.
"""
# bucket_name = 'your-bucket-name'
# blob_name = 'your-object-name'
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(blob_name)
url = blob.generate_signed_url(
version="v4",
# This URL is valid for 15 minutes
expiration=datetime.timedelta(minutes=15),
# Allow GET requests using this URL.
method="GET",
)
print("Generated GET signed URL:")
print(url)
print("You can use this URL with any user agent, for example:")
print("curl '{}'".format(url))
return url
This is how I am trying to import the storage:
from google.cloud import storage
But I am getting the error as:
File "<input>", line 1, in <module>
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: No module named google.cloud
I tried installing google-cloud-storage library also tried installing lots of other google specific libraries but it's still giving the same import error.
Tried: ImportError: No module named google.cloud
ModuleNotFoundError: No module named 'google.cloud' (uninstalling the libraries and again installing)
Edit: how can i generate signurl using python2.7 and app engine ?