简体   繁体   English

Python Firebase 问题没有名为 firebase_admin 的模块

[英]Python Firebase issue No module named firebase_admin

I have deployed a python code in Google App Engine.In my code,tried to import firebase_admin,but it shows following error,我在 Google App Engine 中部署了 python 代码。在我的代码中,尝试导入 firebase_admin,但显示以下错误,

import firebase_admin
ImportError: No module named firebase_admin

hello.py你好.py

import firebase_admin
from firebase_admin import credentials
from firebase_admin import db

I tried simple python code using Terminal: hello.py我使用终端尝试了简单的 python 代码: hello.py

import firebase_admin
print firebase_admin

Output in terminal: Output 在终端:

~/Desktop$ python hello.py
<module 'firebase_admin' from '/usr/local/lib/python2.7/dist-packages/firebase_admin/__init__.pyc'>

Firstly, confirming your package path of executing program.首先,确认你执行程序的包路径。

在此处输入图片说明

Secondly, Perferences --> Project Interpreter ,Make sure the Package install correct path其次, Preferences --> Project Interpreter ,确保包安装路径正确在此处输入图片说明

Anyway , you should use correct python which is installed the package无论如何,您应该使用安装了软件包的正确 python 在此处输入图片说明

通过pip3 install firebase-admin -admin 安装“ pip3 install firebase-admin

根据Hiranya Jayathilaka评论,第三方库必须供应到 Google App Engine 应用程序中。

I was trying to connect cloud firestore through python-admin-sdk using Visual Studio Code which gave me same error我试图使用 Visual Studio Code 通过python-admin-sdk连接cloud firestore ,这给了我同样的错误

Working environment:工作环境:

  1. Ubuntu 20.04 Ubuntu 20.04
  2. Python 3.8.5蟒蛇 3.8.5
  3. firebase-admin 5.0.0 firebase-admin 5.0.0
  4. Visual Studio Code视觉工作室代码

Resolution by re-installing PyLance extension in Visual Studio Code.通过在 Visual Studio Code 中重新安装PyLance扩展来解决。

After unsuccessfully trying all incarnations of pip to install firebase_admin, what worked for me was adding firebase_admin in the requirements.txt file then run pip install -r requirements.txt在尝试所有 pip 版本安装 firebase_admin 失败后,对我有用的是在 requirements.txt文件中添加 firebase_admin然后运行pip install -r requirements.txt

For some reason beyond my understanding, firebase_admin appears to work when installed by referencing the requirements.txt file but not when running pip directly.由于某种超出我理解的原因,firebase_admin 在通过引用 requirements.txt 文件安装时似乎可以工作,但在直接运行 pip 时则不能。

Had the same issue here.这里有同样的问题。 Solved it by updating from python 3.7.9 to 3.9.13 All good now!!!通过从 python 3.7.9 更新到 3.9.13 解决了它现在一切都好!!!

update your更新你的

firebase_admin firebase_admin

to the latest version .到最新版本。 this will solve the issue .这将解决问题。 if nit rename如果 nit 重命名

firebase.py火力基地.py

to some other name... Its working其他名称......它的工作原理

just not use只是不使用

firebase.py火力基地.py

as a name for your project and it will work作为您项目的名称,它将起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM