Just installed Firebase Functions to my project using firebase init functions
and selected Python as my language instead of TS. When I try to deploy the test function I’m getting the error
Error: Could not detect language for functions at /home/foo/bar/myproject/functions
The function is just the default one:
# Welcome to Cloud Functions for Firebase for Python!
# To get started, simply uncomment the below code or create your own.
# Deploy with `firebase deploy`
from firebase_functions import https_fn
from firebase_admin import initialize_app
initialize_app()
@https_fn.on_request()
def on_request_example(req: https_fn.Request) -> https_fn.Response:
return https_fn.Response("Hello world!")
I already have my env set up using poetry and have installed requirements.txt. Is there something I’m missing when choosing python instead of TS?
Update 1
I removed my functions/ folder and recreated my poetry env because hey might get lucky. After manually installing the dependencies with cat functions/requirements.txt | xargs poetry add
then firebase deploy --only fuctions
I’m faced with:
Failed to find location of Firebase Functions SDK: Missing virtual environment at venv directory.
It’s important to note here that I don’t have a venv folder since I’m using poetry and all my envs are in a centralized location. I may be wrong but it looks like Firebase doesn’t want to use my poetry env. Suggestions?
2
Answers
Not really a permanent solution but since the firebase cli is just too stubborn to realize an env was already running I went ahead and created a sym link of the
activate
file it needs to my actual env.Hopefully this can be fixed by being able to identify the location of the activate file in the cli. Or if there is one and I missed it please let me know.
Meanwhile, I'm just happy I can write my functions in python now.😀
Firebase not recognised python correctly.
Check ‘package.json’ file specify the correct runtime of python.