我想把我的Raspberry Pi 4B连接到Firebase Firestore。我使用VS代码和SSH在RPi上编写代码。我完成了所有必要的导入,但是我得到了以下错误:
Failed to import the Cloud Firestore library for Python. Make sure to install the "google-cloud-firestore" module.
错误出现在这一行代码中:
from firebase_admin import firestore
当我在本地计算机上使用PyCharm并进行同样的导入时,一切都进行得很顺利。
这是我的密码:
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
# Use a service account
cred = credentials.Certificate('***.json')
firebase_admin.initialize_app(cred)发布于 2021-12-22 19:08:25
你贴的代码完全没问题。实际上,它与文档相同,这可能表明它与Raspberry Pi有关,并不意味着它有问题,但环境和依赖项可能与您的本地环境和依赖项不同,导致它不在Raspberry中运行,而是在您的计算机上工作。您可以通过在这两者上运行检查包裹来查看它们是否不同。
如果这无助于识别缺少的依赖项,则可以尝试安装所需的包,如grcp
pip install grpcio重新安装“google-云-火药库”
pip install google-cloud-core
pip install google-cloud-firestore或卸载和重新安装“google-云-火药库”
pip uninstall google-cloud-firestore
pip install google-cloud-firestore正如本问题中所建议的那样。
https://stackoverflow.com/questions/70438991
复制相似问题