使用 gsutil CLI 4.51 时如何为 gslib 设置 USER_AGENT?
How to set the USER_AGENT for gslib when using gsutil CLI 4.51?
我想做什么:将文件夹的内容复制到存储桶。我已经在早期版本的 gsutil 中成功地做到了这一点。现在不确定是 python 版本还是导致此问题的 gsutil 版本。有什么见解吗?
命令:gsutil -m cp -r . gs://target-bucket-url
运行: MacOS 10.15.5
尝试上述命令时出现以下错误:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/managers.py", line 243, in serve_client
request = recv()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/connection.py", line 251, in recv
return _ForkingPickler.loads(buf.getbuffer())
File "/Users/user-x/tools/google-cloud-sdk/platform/gsutil/gslib/commands/cp.py", line 30, in <module>
from gslib.command import Command
File "/Users/user-x/tools/google-cloud-sdk/platform/gsutil/gslib/command.py", line 50, in <module>
from gslib.cloud_api_delegator import CloudApiDelegator
File "/Users/user-x/tools/google-cloud-sdk/platform/gsutil/gslib/cloud_api_delegator.py", line 26, in <module>
from gslib.cs_api_map import ApiMapConstants
File "/Users/user-x/tools/google-cloud-sdk/platform/gsutil/gslib/cs_api_map.py", line 23, in <module>
from gslib.gcs_json_api import GcsJsonApi
File "/Users/user-x/tools/google-cloud-sdk/platform/gsutil/gslib/gcs_json_api.py", line 72, in <module>
from gslib.third_party.storage_apitools import storage_v1_client as apitools_client
File "/Users/user-x/tools/google-cloud-sdk/platform/gsutil/gslib/third_party/storage_apitools/storage_v1_client.py", line 26, in <module>
class StorageV1(base_api.BaseApiClient):
File "/Users/user-x/tools/google-cloud-sdk/platform/gsutil/gslib/third_party/storage_apitools/storage_v1_client.py", line 38, in StorageV1
_USER_AGENT += gslib.USER_AGENT
AttributeError: module 'gslib' has no attribute 'USER_AGENT'
gsutil 版本:4.51
python版本:3.8
这是一个已知问题,Google 团队正在研究这个 issue tracker,我建议您去那里并尽可能添加更多信息:AttributeError: module 'gslib' 没有属性 'USER_AGENT'
按照 issue 跟踪器中的建议将 python 版本设置为 python 3.7 对我有用。以下是工作配置。
$ cat ~/.bash_profile
alias python='python3.7'
.....
$ source ~/.bash_profile
我想做什么:将文件夹的内容复制到存储桶。我已经在早期版本的 gsutil 中成功地做到了这一点。现在不确定是 python 版本还是导致此问题的 gsutil 版本。有什么见解吗?
命令:gsutil -m cp -r . gs://target-bucket-url
运行: MacOS 10.15.5
尝试上述命令时出现以下错误:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/managers.py", line 243, in serve_client
request = recv()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/connection.py", line 251, in recv
return _ForkingPickler.loads(buf.getbuffer())
File "/Users/user-x/tools/google-cloud-sdk/platform/gsutil/gslib/commands/cp.py", line 30, in <module>
from gslib.command import Command
File "/Users/user-x/tools/google-cloud-sdk/platform/gsutil/gslib/command.py", line 50, in <module>
from gslib.cloud_api_delegator import CloudApiDelegator
File "/Users/user-x/tools/google-cloud-sdk/platform/gsutil/gslib/cloud_api_delegator.py", line 26, in <module>
from gslib.cs_api_map import ApiMapConstants
File "/Users/user-x/tools/google-cloud-sdk/platform/gsutil/gslib/cs_api_map.py", line 23, in <module>
from gslib.gcs_json_api import GcsJsonApi
File "/Users/user-x/tools/google-cloud-sdk/platform/gsutil/gslib/gcs_json_api.py", line 72, in <module>
from gslib.third_party.storage_apitools import storage_v1_client as apitools_client
File "/Users/user-x/tools/google-cloud-sdk/platform/gsutil/gslib/third_party/storage_apitools/storage_v1_client.py", line 26, in <module>
class StorageV1(base_api.BaseApiClient):
File "/Users/user-x/tools/google-cloud-sdk/platform/gsutil/gslib/third_party/storage_apitools/storage_v1_client.py", line 38, in StorageV1
_USER_AGENT += gslib.USER_AGENT
AttributeError: module 'gslib' has no attribute 'USER_AGENT'
gsutil 版本:4.51 python版本:3.8
这是一个已知问题,Google 团队正在研究这个 issue tracker,我建议您去那里并尽可能添加更多信息:AttributeError: module 'gslib' 没有属性 'USER_AGENT'
按照 issue 跟踪器中的建议将 python 版本设置为 python 3.7 对我有用。以下是工作配置。
$ cat ~/.bash_profile
alias python='python3.7'
.....
$ source ~/.bash_profile