Skip to content Skip to sidebar Skip to footer

Firebase Admin Sdk With Flask Throws Error No Module Named 'firebase_admin'

--- Question closed It was my mistake, my uWSGI startup script switches to a different virtualenv. --- Original question I'm trying to publish push notifications from my Flask app

Solution 1:

How did you install/add the firebase_admin package to your project?

If you haven't explicitly installed/added the package, I've only come across a few cases (there may be other cases/solutions as well), that gives off the error ModuleNotFoundError: No module named 'firebase_admin':

PyCharm

If using PyCharm, you can install/add it from the PyCharm preferences

  • File > Preferences > Project > Project Interpreter
  • Click the add button, search for firebase, select the appropriate package: firebase-admin
  • Click "Install Package" button.

Visual Studio Code / Alternative installation

I use Visual Studio Code, and opted to install firebase_admin libraries into the virtualenv using a requirements.txt file saved in the root directory. You can still use this method even if you're using PyCharm:

1) Activate your environment

2) Create a requirements.txt file with the following contents:

firebase_admin
// other packages

3) Run pip install

pip install -r requirements.txt

4) After installing, you can confirm that's already available by checking the site-packages folder in the following directory:

env/lib/site-packages/firebase_admin
env/lib/site-packages/firebase_admin-<version>.dist-info

5) Try running the code again.

Hope that helps!

Solution 2:

Run this command pip install firebase-admin flask

Post a Comment for "Firebase Admin Sdk With Flask Throws Error No Module Named 'firebase_admin'"