{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/5254","repository_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/5254/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/5254/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/5254/events","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-python/issues/5254","id":318482022,"number":5254,"title":"Error message when downloading blob to local file","user":{"login":"lordcenzin","id":30053696,"avatar_url":"https://avatars2.githubusercontent.com/u/30053696?v=4","gravatar_id":"","url":"https://api.github.com/users/lordcenzin","html_url":"https://github.com/lordcenzin","followers_url":"https://api.github.com/users/lordcenzin/followers","following_url":"https://api.github.com/users/lordcenzin/following{/other_user}","gists_url":"https://api.github.com/users/lordcenzin/gists{/gist_id}","starred_url":"https://api.github.com/users/lordcenzin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lordcenzin/subscriptions","organizations_url":"https://api.github.com/users/lordcenzin/orgs","repos_url":"https://api.github.com/users/lordcenzin/repos","events_url":"https://api.github.com/users/lordcenzin/events{/privacy}","received_events_url":"https://api.github.com/users/lordcenzin/received_events","type":"User","site_admin":false},"labels":[{"id":77678602,"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/labels/api:%20storage","name":"api: storage","color":"f8f8f8","default":false},{"id":77438584,"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/labels/type:%20question","name":"type: question","color":"c5def5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-27T17:02:12Z","updated_at":"2018-04-27T22:01:58Z","closed_at":null,"author_association":"NONE","body":"Dear all,\r\ni am facing a very weird issue when I try to download an existing file in gcs to local machine (in this case Datalab)\r\nFirst of all additional machine information (retrieved through datalab):\r\n```\r\nPython 3.5.5\r\nrequests: 2.9.1\r\nName: google-cloud\r\nVersion: 0.30.0\r\nSummary: API Client library for Google Cloud\r\nHome-page: https://github.com/GoogleCloudPlatform/google-cloud-python\r\nAuthor: Google Cloud Platform\r\nAuthor-email: googleapis-publisher@google.com\r\nLicense: Apache 2.0\r\nLocation: /usr/local/envs/py3env/lib/python3.5/site-packages\r\nRequires: google-cloud-videointelligence, google-cloud-core, google-cloud-dns, google-cloud-bigquery, google-cloud-spanner, google-cloud-pubsub, google-cloud-resource-manager, google-cloud-runtimeconfig, google-cloud-firestore, google-cloud-monitoring, google-cloud-storage, google-cloud-translate, google-cloud-language, google-cloud-trace, google-cloud-logging, google-cloud-vision, google-cloud-error-reporting, google-cloud-speech, google-cloud-bigtable, google-api-core, google-cloud-datastore`\r\nRequired-by: datalab\r\n```\r\n\r\nThis is the scenario:\r\n\r\n```python\r\nfrom google.cloud import storage\r\nbucket_name = 'my-bucket'\r\nfile_name = 'dataset/myvideo.mp4'\r\nclient = storage.Client()\r\nbucket = client.get_bucket(bucket_name)\r\nblob = bucket.blob(file_name)\r\noutfile = 'myvideo.mp4'\r\nbucket = storage_client.get_bucket(bucket_name)\r\nblob = bucket.blob(file_name)\r\nblob.download_to_filename(outfile)\r\n```\r\n\r\nI obtain the following error (reported stacktrace)\r\n\r\n```python\r\n---------------------------------------------------------------------------\r\nAttributeError                            Traceback (most recent call last)\r\n<ipython-input-96-54968afe5841> in <module>()\r\n      5 blob = bucket.blob(file_name)\r\n      6 # Download the file to a destination\r\n----> 7 blob.download_to_filename(outfile)\r\n\r\n/usr/local/envs/py3env/lib/python3.5/site-packages/google/cloud/storage/blob.py in download_to_filename(self, filename, client)\r\n    519         try:\r\n    520             with open(filename, 'wb') as file_obj:\r\n--> 521                 self.download_to_file(file_obj, client=client)\r\n    522         except resumable_media.DataCorruption as exc:\r\n    523             # Delete the corrupt downloaded file.\r\n\r\n/usr/local/envs/py3env/lib/python3.5/site-packages/google/cloud/storage/blob.py in` `download_to_file(self, file_obj, client)\r\n    497         transport = self._get_transport(client)\r\n    498         try:\r\n--> 499             self._do_download(transport, file_obj, download_url, headers)\r\n    500         except resumable_media.InvalidResponse as exc:\r\n    501             _raise_from_invalid_response(exc)\r\n\r\n/usr/local/envs/py3env/lib/python3.5/site-packages/google/cloud/storage/blob.py in _do_download(self, transport, file_obj, download_url, headers)\r\n    447         if self.chunk_size is None:\r\n    448             download = Download(download_url, stream=file_obj, headers=headers)\r\n--> 449             download.consume(transport)\r\n    450         else:\r\n    451             download = ChunkedDownload(\r\n\r\n/usr/local/envs/py3env/lib/python3.5/site-packages/google/resumable_media/requests/download.py in` consume(self, transport)\r\n    172 \r\n    173         if self._stream is not None:\r\n--> 174             self._write_to_stream(result)\r\n    175 \r\n    176         return result\r\n\r\n/usr/local/envs/py3env/lib/python3.5/site-packages/google/resumable_media/requests/download.py in _write_to_stream(self, response)\r\n    115         else:\r\n    116             md5_hash = hashlib.md5()\r\n--> 117         with response:\r\n    118             # NOTE: This might \"donate\" ``md5_hash`` to the decoder and replace\r\n    119             #       it with a ``_DoNothingHash``.\r\n\r\nAttributeError: __exit__\r\n```"},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/comments/385105320","html_url":"https://github.com/GoogleCloudPlatform/google-cloud-python/issues/5254#issuecomment-385105320","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/google-cloud-python/issues/5254","id":385105320,"user":{"login":"tseaver","id":242750,"avatar_url":"https://avatars2.githubusercontent.com/u/242750?v=4","gravatar_id":"","url":"https://api.github.com/users/tseaver","html_url":"https://github.com/tseaver","followers_url":"https://api.github.com/users/tseaver/followers","following_url":"https://api.github.com/users/tseaver/following{/other_user}","gists_url":"https://api.github.com/users/tseaver/gists{/gist_id}","starred_url":"https://api.github.com/users/tseaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tseaver/subscriptions","organizations_url":"https://api.github.com/users/tseaver/orgs","repos_url":"https://api.github.com/users/tseaver/repos","events_url":"https://api.github.com/users/tseaver/events{/privacy}","received_events_url":"https://api.github.com/users/tseaver/received_events","type":"User","site_admin":false},"created_at":"2018-04-27T22:01:58Z","updated_at":"2018-04-27T22:01:58Z","author_association":"MEMBER","body":"What version of `google-cloud-storage` is installed?  E.g.:\r\n\r\n```bash\r\n$ pip show google-cloud-storage\r\n```"}}
{"actor":{"display_login":"tseaver"}}