部署到gcp应用引擎后无法连接到云存储

时间:2019-07-24 21:33:45

标签: python python-3.x google-app-engine google-cloud-platform google-cloud-storage

我正在App Engine VM上开发Flask应用。我想将文件上传到Google Cloud Storage,因此我使用storage_client = storage.Client()连接到Cloud Storage。仅在VM中进行测试时,我的应用程序运行正常,没有错误。但是,在我使用gcloud app deploy进行部署并在已部署的应用程序上测试了上传功能之后,它失败并返回了Internet 500错误。日志显示了追溯,这是由于连接到云存储的代码行:storage_client = storage.Client()

具体错误为__init__() takes 2 positional arguments but 3 were given,显示在云存储库函数中。我有这个应用程序的python 3.5,我真的不知道如何解决这个问题。任何帮助将不胜感激!

Traceback (most recent call last):
  File \"/env/lib/python3.5/site-packages/flask/app.py\", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File \"/env/lib/python3.5/site-packages/flask/app.py\", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File \"/env/lib/python3.5/site-packages/flask/app.py\", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File \"/env/lib/python3.5/site-packages/flask/_compat.py\", line 35, in reraise
    raise value
  File \"/env/lib/python3.5/site-packages/flask/app.py\", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File \"/env/lib/python3.5/site-packages/flask/app.py\", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File \"/home/vmagent/app/main.py\", line 59, in select_date
    generate_report(log_lists)
  File \"/home/vmagent/app/main.py\", line 83, in generate_report
    storage_client = storage.Client()
  File \"/env/lib/python3.5/site-packages/google/cloud/storage/client.py\", line 86, in __init__
    self._connection = Connection(self, client_info=client_info)
  File \"/env/lib/python3.5/site-packages/google/cloud/storage/_http.py\", line 33, in __init__
    super(Connection, self).__init__(client, client_info)
TypeError: __init__() takes 2 positional arguments but 3 were given

下面是我的“ requirements.txt”:

Flask==1.0.2
gunicorn==19.9.0
firebase-admin==2.13.0
google-cloud-firestore==0.29.0
google-cloud-storage==1.17.0
lxml==3.7.3

1 个答案:

答案 0 :(得分:2)

您正在使用旧库。更新您的requirements.txt以使用当前版本。

例如:

您正在使用google-cloud-firestore==0.29.0,但当前版本是google-cloud-firestore==1.3.0

您的大多数模块已过时,在某些情况下不兼容(以及旧库与当前库不兼容)。