9

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'>
Ramprasad
  • 7,745
  • 20
  • 69
  • 127
  • 1
    Have you installed the package? `pip install firebase-admin` – Thomas Aug 07 '17 at 19:02
  • @ThomasMey Yes I installed sudo pip install firebase-admin...it successfully installed..but still this error occurs... – Ramprasad Aug 08 '17 at 04:45
  • @ThomasMey I am using PyCharm in my Linux...Is it any issue for install firebase-admin on local machine? – Ramprasad Aug 08 '17 at 09:23
  • 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. – Thomas Aug 08 '17 at 09:26
  • @ThomasMey I have updated my question,have a look... – Ramprasad Aug 08 '17 at 09:51
  • Check this answer: https://stackoverflow.com/a/37316449/4026792 Your problem is that Pycharm doesn't use the local python iirc – Thomas Aug 08 '17 at 19:04
  • @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_admin – Ramprasad Aug 10 '17 at 13:12
  • 2
    Have you vendored the library into your App Engine app? https://cloud.google.com/appengine/docs/standard/python/tools/using-libraries-python-27#installing_a_third-party_library – Hiranya Jayathilaka Aug 10 '17 at 17:18
  • @hiranya-jayathilaka after vendored the library works fine – Ramprasad Aug 16 '17 at 17:13

6 Answers6

6

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

ijas
  • 272
  • 4
  • 6
5

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

Yang MingHui
  • 360
  • 4
  • 13
0

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

snakecharmerb
  • 36,887
  • 10
  • 71
  • 115
0

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.

Nishant Patel
  • 1,130
  • 12
  • 19
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.

wandesky
  • 76
  • 1
  • 6
-5

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

Gautam Kumar
  • 1,129
  • 12
  • 17