无法在Python库中导入firebase admin

问题描述 投票:0回答:1

我正在尝试使用 firebase admin 的 python 库。 但是,当我尝试使用以下方式导入库时:

from firebase_admin import firestore

我收到以下错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mnjuhn/Library/Python/3.8/lib/python/site-packages/firebase_admin/firestore.py", line 27, in <module>
    from google.cloud import firestore
  File "/Users/mnjuhn/Library/Python/3.8/lib/python/site-packages/google/cloud/firestore/__init__.py", line 18, in <module>
    from google.cloud.firestore_v1 import gapic_version as package_version
  File "/Users/mnjuhn/Library/Python/3.8/lib/python/site-packages/google/cloud/firestore_v1/__init__.py", line 37, in <module>
    from google.cloud.firestore_v1.async_client import AsyncClient
  File "/Users/mnjuhn/Library/Python/3.8/lib/python/site-packages/google/cloud/firestore_v1/async_client.py", line 43, in <module>
    from google.cloud.firestore_v1.services.firestore import (
  File "/Users/mnjuhn/Library/Python/3.8/lib/python/site-packages/google/cloud/firestore_v1/services/firestore/__init__.py", line 16, in <module>
    from .client import FirestoreClient
  File "/Users/mnjuhn/Library/Python/3.8/lib/python/site-packages/google/cloud/firestore_v1/services/firestore/client.py", line 62, in <module>
    from google.cloud.location import locations_pb2  # type: ignore
  File "/Users/mnjuhn/Library/Python/3.8/lib/python/site-packages/google/cloud/location/locations_pb2.py", line 30, in <module>
    from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api/annotations_pb2.py", line 42, in <module>
    google_dot_protobuf_dot_descriptor__pb2.MethodOptions.RegisterExtension(http)
AttributeError: type object 'MethodOptions' has no attribute 'RegisterExtension'
>>> 

我的python版本是3.8.2,我安装了以下库:

警告:pip 正在由旧的脚本包装器调用。这在 pip 的未来版本中将失败。 请参阅https://github.com/pypa/pip/issues/5599以获取有关解决根本问题的建议。 为了避免这个问题,您可以使用“-m pip”调用 Python,而不是直接运行 pip。

------------------------ ----------
CacheControl             0.14.1
cachetools               4.0.0
certifi                  2019.11.28
cffi                     1.17.1
chardet                  3.0.4
cryptography             43.0.3
firebase                 4.0.1
firebase-admin           6.6.0
google-api-core          2.22.0
google-api-python-client 1.7.11
google-auth              2.36.0
google-auth-httplib2     0.0.3
google-cloud-core        2.4.1
google-cloud-firestore   2.19.0
google-cloud-storage     2.18.2
google-crc32c            1.5.0
google-resumable-media   2.7.2
googleapis-common-protos 1.65.0
grpcio                   1.67.1
grpcio-status            1.67.1
httplib2                 0.17.0
idna                     2.9
msgpack                  1.0.0
pip                      24.3.1
proto-plus               1.25.0
protobuf                 5.28.3
pyasn1                   0.4.8
pyasn1-modules           0.2.8
pycparser                2.22
PyJWT                    2.9.0
pytz                     2019.3
requests                 2.23.0
rsa                      4.0
setuptools               41.2.0
six                      1.14.0
uritemplate              3.0.1
urllib3                  1.25.8
wheel                    0.45.0
python firebase
1个回答
0
投票

通过将 python3 升级到 python 版本 3.12.7 并重新安装 firebase-admin 解决了此问题。

© www.soinside.com 2019 - 2024. All rights reserved.