如果使用python和子进程从pycharm进行调用,则gsutil无法正常工作,“无法导入名称_common”

时间:2019-05-17 09:17:21

标签: python pycharm gsutil

我已经编写了一个python脚本来自动执行一些gsutil操作。 如果我通过命令行运行,则gsutil可以正常运行。但是,如果我在python中将相同的命令与子进程一起翻译,则会收到错误消息:

BUCKET_NAME = 'datastore-backup'
FOLDER_NAME = 'my_folder'

gcs_path = os.path.join('gs://', BUCKET_NAME, FOLDER_NAME)

files = subprocess.check_output(['gsutil', 'ls', gcs_path], stderr=sys.stdout)
print(files)

我收到此错误

Traceback (most recent call last):
  File "/Users/dario/Downloads/google-cloud-sdk/bin/bootstrapping/gsutil.py", line 13, in <module>
    import bootstrapping
  File "/Users/dario/Downloads/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 32, in <module>
    import setup  # pylint:disable=g-import-not-at-top
  File "/Users/dario/Downloads/google-cloud-sdk/bin/bootstrapping/setup.py", line 55, in <module>
    from googlecloudsdk.core import properties
  File "/Users/dario/Downloads/google-cloud-sdk/lib/googlecloudsdk/core/properties.py", line 34, in <module>
    from googlecloudsdk.core.util import times
  File "/Users/dario/Downloads/google-cloud-sdk/lib/googlecloudsdk/core/util/times.py", line 55, in <module>
    from dateutil.tz import _common as tz_common
ImportError: cannot import name _common

任何帮助

0 个答案:

没有答案