0
我試圖從我的教練應用程序在雲ML引擎中運行時從雲存儲中下載文件。但是,當我嘗試下載文件時,出現以下錯誤。 我有權訪問雲存儲路徑。無法從雲ML引擎中的教練應用程序下載Google雲存儲文件
錯誤:
blob.download_to_filename(destination_file_name) File "/root/.local/lib/python2.7/site-packages/google/cloud/storage/blob.py", line 482, in download_to_filename self.download_to_file(file_obj, client=client) File "/root/.local/lib/python2.7/site-packages/google/cloud/storage/blob.py", line 464, in download_to_file self._do_download(transport, file_obj, download_url, headers) File "/root/.local/lib/python2.7/site-packages/google/cloud/storage/blob.py", line 418, in _do_download download.consume(transport) File "/root/.local/lib/python2.7/site-packages/google/resumable_media/requests/download.py", line 101, in consume self._write_to_stream(result) File "/root/.local/lib/python2.7/site-packages/google/resumable_media/requests/download.py", line 62, in _write_to_stream with response: AttributeError: __exit__
下面是下載GCS文件的代碼:
storage_client = storage.Client()
bucket = storage_client.get_bucket(bucket_name)
blob = bucket.blob(key)
blob.download_to_filename(destination_file_name)
我沒有提供任何GCP憑據Client
作爲訓練者應用軟件的運行可以通過訪問其他文件
tf.train.string_input_producer
任何幫助,將不勝感激。
謝謝。這非常有幫助。不知道爲什麼它不符合我嘗試的方式。 –