Google 存储 Python API 类型错误

Google Storage Python API typeError

我正在尝试将 Python 客户端库用于 Google 云存储。当我尝试初始化客户端时出现类型错误。但是我找不到任何参考资料。


TypeError                                 Traceback (most recent call last)
<ipython-input-8-c05b3b802290> in <module>()
----> 1 storage_client = storage.Client()

/opt/anaconda3/envs/python35/lib/python3.5/site-packages/google/cloud/storage/client.py in __init__(self, project, credentials, _http, client_info)
     84         if no_project:
     85             self.project = None
---> 86         self._connection = Connection(self, client_info=client_info)
     87         self._batch_stack = _LocalStack()
     88 

/opt/anaconda3/envs/python35/lib/python3.5/site-packages/google/cloud/storage/_http.py in __init__(self, client, client_info)
     31 
     32     def __init__(self, client, client_info=None):
---> 33         super(Connection, self).__init__(client, client_info)
     34 
     35         self._client_info.gapic_version = __version__

TypeError: __init__() takes 2 positional arguments but 3 were given

我的代码非常简单,其他云库按预期工作:

import os
from google.cloud import storage
from google.cloud import bigquery

os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/.google.json"
bigquery_client = bigquery.Client()
storage_client = storage.Client()

我的云 AMI 已相应设置(服务帐户):

BigQuery Admin
Storage Admin 

Python环境是3.5

您的问题看起来像是库不匹配。

要查看的项目:

  1. Install/update 库到最新版本。
  2. 安装最新的 Python 包。
  3. 为每个程序使用 virtualenv,这样库和编译器版本就不是问题。