Python Firebase issue No module named firebase_admin
Asked Answered
B

10

17

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'>
Burnham answered 7/8, 2017 at 18:28 Comment(9)
Have you installed the package? pip install firebase-adminScraggy
@ThomasMey Yes I installed sudo pip install firebase-admin...it successfully installed..but still this error occurs...Burnham
@ThomasMey I am using PyCharm in my Linux...Is it any issue for install firebase-admin on local machine?Burnham
I'm using neither Pycharm nor Linux so I can't tell, but I'd recommend to just try it: Open the console, run python and enter import firebase_admin or just one of the lines above. If it works, it's Pycharm's fault.Scraggy
@ThomasMey I have updated my question,have a look...Burnham
Check this answer: https://mcmap.net/q/745486/-how-to-install-modules-correctly-in-pycharm Your problem is that Pycharm doesn't use the local python iircScraggy
@ThomasMey In local Pycharm it is added properly,On AppEngine,it shows same error,No module named firebase_admin.Even on appengine,pip list shows firebase_adminBurnham
Have you vendored the library into your App Engine app? cloud.google.com/appengine/docs/standard/python/tools/…Beachhead
@hiranya-jayathilaka after vendored the library works fineBurnham
H
17

Install "firebase-admin" by pip3 install firebase-admin

Hooked answered 23/10, 2020 at 9:22 Comment(0)
H
7

Firstly, confirming your package path of executing program.

enter image description here

Secondly, Perferences --> Project Interpreter ,Make sure the Package install correct path enter image description here

Anyway, you should use correct python which is installed the packageenter image description here

Hedrick answered 5/2, 2018 at 6:40 Comment(0)
B
1

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

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

Blum answered 10/5, 2021 at 21:39 Comment(0)
H
1

For me the problem was that I installed using pip and not pip3.

After correctly installing firebase_admin I also included this on .zshrc:

export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH" 
alias python=python3
alias pip=pip3

Bonus tip:

Check Python version on pyvenv.cfg file, make sure to update Python if necessary and set the latest version to default as described on the first line above. Make sure to replace @3.11 with your latest version.

Hulahula answered 2/7, 2023 at 15:51 Comment(0)
H
1

For me it worked when I changed my interpreter to an earlier version of Python: I went from 3.11.7.1 to 3.9.6

Holierthanthou answered 11/2 at 11:9 Comment(0)
S
0

Per Hiranya Jayathilaka's comment, third party libraries must be vendored into Google App Engine applications.

Samoyed answered 7/8, 2017 at 18:28 Comment(0)
F
0

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.

Fairley answered 13/8, 2021 at 10:12 Comment(0)
K
0

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

Keeshakeeshond answered 29/8, 2022 at 1:58 Comment(0)
I
0

to solve all the problems regarding this face_recognition module first I have installed cmake in the current working terminal of pycharm using pip install cmake then for the dlib I have used pip install dlib it showed me a error that failed to build wheel I have the installed the wheel from https://github.com/sachadee/Dlib I have done all this in python 3.9 and I have no issues in solving all these errors it is better to use python 3.9.0

Isbell answered 3/3 at 7:27 Comment(0)
S
-7

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

Simultaneous answered 12/1, 2018 at 7:31 Comment(1)
That error message is just because missing firebase_admin Python module. So, how do you "update it to the last version"? Also, nobody here is using firebase.py as Python script name.Laclair

© 2022 - 2024 — McMap. All rights reserved.