簡體   English   中英

找不到模塊 (google.cloud.location)

[英]Module not found (google.cloud.location)

突然我的 web 應用程序無法運行。 一直沒有錯誤,沒有對“firestore”的特定代碼進行任何更改。

  • 谷歌雲/應用引擎標准
  • 蟒蛇310
  • 工作在雲端 Shell / 雲端編輯
Traceback (most recent call last):
  File "/layers/google.python.pip/pip/lib/python3.10/site-packages/flask/app.py", line 2070, in wsgi_app
    response = self.full_dispatch_request()
  File "/layers/google.python.pip/pip/lib/python3.10/site-packages/flask/app.py", line 1515, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/layers/google.python.pip/pip/lib/python3.10/site-packages/flask/app.py", line 1513, in full_dispatch_request
    rv = self.dispatch_request()
  File "/layers/google.python.pip/pip/lib/python3.10/site-packages/flask/app.py", line 1499, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/srv/main.py", line 42, in landing_page
    import m_landing_page
  File "/srv/m_landing_page.py", line 4, in <module>
    import storagelayer
  File "/srv/storagelayer.py", line 16, in <module>
    from google.cloud import firestore
  File "/layers/google.python.pip/pip/lib/python3.10/site-packages/google/cloud/firestore/__init__.py", line 18, in <module>
    from google.cloud.firestore_v1 import __version__
  File "/layers/google.python.pip/pip/lib/python3.10/site-packages/google/cloud/firestore_v1/__init__.py", line 36, in <module>
    from google.cloud.firestore_v1.async_client import AsyncClient
  File "/layers/google.python.pip/pip/lib/python3.10/site-packages/google/cloud/firestore_v1/async_client.py", line 45, in <module>
    from google.cloud.firestore_v1.async_transaction import AsyncTransaction
  File "/layers/google.python.pip/pip/lib/python3.10/site-packages/google/cloud/firestore_v1/async_transaction.py", line 49, in <module>
    from google.cloud.firestore_v1.client import Client
  File "/layers/google.python.pip/pip/lib/python3.10/site-packages/google/cloud/firestore_v1/client.py", line 44, in <module>
    from google.cloud.firestore_v1.services.firestore import client as firestore_client
  File "/layers/google.python.pip/pip/lib/python3.10/site-packages/google/cloud/firestore_v1/services/firestore/__init__.py", line 16, in <module>
    from .client import FirestoreClient
  File "/layers/google.python.pip/pip/lib/python3.10/site-packages/google/cloud/firestore_v1/services/firestore/client.py", line 55, in <module>
    from google.cloud.location import locations_pb2  # type: ignore
ModuleNotFoundError: No module named 'google.cloud.location'"

嘗試(1)安裝 pip install --upgrade google-cloud-firestore in Cloud shell

(2)

    change db = firestore.Client()
    to

db = firestore.Client(project=' ... ') # ... my project


我剛才在嘗試將 Python 腳本鏈接到 Firestore 時遇到了這個完全相同的錯誤。 我不知道這是否是一個“正確”的解決方案,但在執行此操作后我讓我的代碼運行並將數據保存到我的 Firestore 數據庫中。

在錯誤消息中,此行指定了導入 google.cloud.location 的文件:

  File "/layers/google.python.pip/pip/lib/python3.10/site-packages/google/cloud/firestore_v1/services/firestore/client.py", line 55, in <module>

如果您打開 client.py 文件並注釋掉第 55 行(“from google.cloud.location import locations_pb2 # type: ignore”),然后再次運行您的代碼,下一條錯誤消息將顯示 google.cloud 所在的其他文件.location 正在導入。 對導入此模塊的所有五個文件重復此過程。 (client.py, base.py, grpc.py, grpc_asyncio.py, async_client.py)

通過搜索代碼,我看到從未使用過 locations_pb2(從 google.cloud.location 導入)。 我懷疑將其完全注釋掉不會影響 firebase_admin 的功能。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM