简体   繁体   中英

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,

import firebase_admin
ImportError: No module named firebase_admin

hello.py

import firebase_admin
from firebase_admin import credentials
from firebase_admin import db

I tried simple python code using Terminal: hello.py

import firebase_admin
print firebase_admin

Output in terminal:

~/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在此处输入图片说明

Anyway , you should use correct python which is installed the package 在此处输入图片说明

通过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

Working environment:

  1. Ubuntu 20.04
  2. Python 3.8.5
  3. firebase-admin 5.0.0
  4. Visual Studio Code

Resolution by re-installing PyLance extension in Visual Studio Code.

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

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.

Had the same issue here. Solved it by updating from python 3.7.9 to 3.9.13 All good now!!!

update your

firebase_admin

to the latest version . this will solve the issue . if nit rename

firebase.py

to some other name... Its working

just not use

firebase.py

as a name for your project and it will work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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