部署到gcp app engin后未能连接到云存储

2024-04-25 16:53:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在appengine虚拟机上开发一个Flask应用程序。我想上传文件到Google云存储,所以我使用storage_client = storage.Client()连接到云存储。我的应用程序是完美的工作时,没有错误的VM单独测试。但是,在我使用gcloud app deploy部署并在部署的应用程序上测试upload函数之后,它失败并返回Internet 500错误。日志显示了回溯,这是由于连接到云存储的代码行:storage_client = storage.Client()

具体的错误是__init__() takes 2 positional arguments but 3 were given显示在云存储库函数中。我有这个应用程序的python3.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

下面是我的”要求.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

Tags: inpyselfenvclientappflaskinit
1条回答
网友
1楼 · 发布于 2024-04-25 16:53:30

您正在使用旧库。更新您的要求.txt使用当前版本。你知道吗

例如:

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

您的大多数模块都过时了,在某些情况下不兼容(古代库和当前库)。你知道吗

相关问题 更多 >