You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Functions Python version conflict 3.12 and 3.11 #6774
Attempt to run the emulators and it complains that you're not using Python 3.11
Failed to load function definition from source: FirebaseError: Failed to find location of Firebase Functions SDK. Did you forget to run '. "<redacted>/venv/bin/activate" && python3.11 -m pip install -r requirements.txt'?
Install Python 3.11
Build the venv using 3.11
Install pip requirements using 3.11
Emulators run
Attempt to deploy the functions and it complains that you're not using Python 3.12
Error: Failed to find location of Firebase Functions SDK. Did you forget to run '. "<redacted>/venv/bin/activate" && python3.12 -m pip install -r requirements.txt'?
[REQUIRED] Expected behavior
Emulators should work with Python 3.12 and deploy should work with Python 3.11 when both are installed.
[REQUIRED] Actual behavior
Emulators fail to start the Python functions if the venv was setup using 3.12
Deploy fails when venv was setup using 3.11 if 3.12 is also installed
Reacted by Marina, Mario Cecchi, Bhanuka Isuru, hilario and Eshan Mushtaq
I've got the same issue: since firebase-tools switched to version 13.3.0, my Github Actions builds fail to deploy Python Cloud functions (I am using python3.11, and with [email protected] it was working fine).
Run npx firebase-tools deploy --only functions --force --json --project *** --token ***
npm WARN exec The following package was not found and will be installed: [email protected]
***
"status": "error",
"error": "Failed to find location of Firebase Functions SDK. Did you forget to run '. \"/home/runner/work/webapp/webapp/functions-python/venv/bin/activate\" && python3.12 -m pip install -r requirements.txt'?"
***
PS Of course the fix is to simply to pre-install the working version, so this is just to report the bug on the new version.
But I think it makes more sense to use the default python binary than to find the latest version when the configuration is missing, which is already done by getPythonBinary.
Reacted by bboySubZero, Ifeoluwa Andrew Omole , Hussaini Usman and Henning K
Reacted by Yam Horesh, Matheus Saulo, James Jesudason, mjbates7, bboySubZero, Malachi Cunliffe, thekevingibbons, Ifeoluwa Andrew Omole , Marco Voegeli and Maier Raul
Reacted by Marina, Mario Cecchi, Alex, Trevor Grant, antho-data, Matheus Saulo, Dario Bernardo, bboySubZero, thekevingibbons, William Amaral and 4 more
Hey folks, thanks for reporting this issue, and thanks @kmsbernard, for sharing your observations. I’m unable to reproduce the issue when using python3.12, however I was able to reproduce this using python3.11.
Let me know in case I made a mistake in following the provided steps. From what I can tell, the steps are:
Run firebase init functions --project <project_id>
Choose Python
Do you want to install dependencies now? No
Run cd functions
Run python3.11 -m venv venv
Run . venv/bin/activate && python3.11 -m pip install -r requirements.txt
Uncomment the example function in main.py
Run firebase emulators:start
Emulators raise an issue
It does seem like the issue here is that firebase-tools tries to find the latest version of python(currently 3.12). Setting the runtime as mentioned in #6774 (comment) fixes the issue.
Let me raise this issue to our engineering team so that we can determine the appropriate action for this. Also, feel free to make a PR for this if you’re up for it! Contributions are always welcome.
@kmsbernard That's awesome, thanks! We're going to set this and see how it behaves.
@aalej Thanks for looking into this, my steps to reproduce might have been a bit off as we're mainly getting this issue on a Github Actions runner that has at least 6 different Python versions vs a local environment that we have more control over. Some is local in the case of the emulators, some is the runner in the case of the error using Python 3.12 instead of 3.11.
It all stems from not having the runtime option configured in firebase.json. I think maybe another question is "Should firebase init functions be initializing the runtime option?" In my "ignorant Firebase noob" world, the answer to that question is "Yes, it should initialize to the latest version the platform supports." As it stands right now, I didn't even realize it wasn't set and firebase-tools was trying to reason about it. If it were set by default (or even erroring if not specified), the necessity of reasoning about it is basically eliminated and it becomes the responsibility of the user to make sure it's set correctly.
Hello. I can reproduce this issue with Python 3.11 as well. Adding a runtime does fix it, however my LSP does warn me of a unknown value. I'm guessing the schema for firebase.json is not updated.
LSP warning in JSON:
Value is not accepted. Valid values: "nodejs10", "nodejs12", "nodejs14", "nodejs16", "nodejs18", "nodejs20".
const runtime = context.runtime ? context.runtime : LATEST_VERSION;
But I think it makes more sense to use the default python binary than to find the latest version when the configuration is missing, which is already done by getPythonBinary.
if (runtime === "python310") {
return "python3.10";
} else if (runtime === "python311") {
return "python3.11";
} else if (runtime === "python312") {
return "python3.12";
}
return "python";
I think I'll make PR for it
Just a heads up:
Firebase's latest release (v14.4.0) now defaults with python3.13.
Using the quoted solution (adding the "runtime" variable with your python version (e.g. 312) patches this issue). Updating the codebase to something more future-proof could be nice 👍
Activity
antopolskiy commentedon Feb 16, 2024
I've got the same issue: since firebase-tools switched to version 13.3.0, my Github Actions builds fail to deploy Python Cloud functions (I am using python3.11, and with [email protected] it was working fine).
PS Of course the fix is to simply to pre-install the working version, so this is just to report the bug on the new version.
curtis-jotson commentedon Feb 16, 2024
@antopolskiy So far our fix has been to pin
firebase-toolsto 13.2.1 for now.kmsbernard commentedon Feb 20, 2024
I got the same error and found a fix.
This error occurred when the runtime configuration was omitted from
firebase.json. If your runtime is using python 3.11, it should look like this:{ "functions": [ { "source": "functions", "codebase": "default", "runtime": "python311", <--- here } ], }If the config is omitted,
firebase-toolsattempt to find latest python version.firebase-tools/src/deploy/functions/runtimes/python/index.ts
Line 33 in 09c2641
But I think it makes more sense to use the default python binary than to find the latest version when the configuration is missing, which is already done by
getPythonBinary.firebase-tools/src/deploy/functions/runtimes/python/index.ts
Lines 50 to 57 in 09c2641
I think I'll make PR for it
kmsbernard commentedon Feb 20, 2024
After further reading, it seems more reasonable to throw an error when the runtime field is missing, since the node.js function is already doing so.
aalej commentedon Feb 20, 2024
Hey folks, thanks for reporting this issue, and thanks @kmsbernard, for sharing your observations. I’m unable to reproduce the issue when using python3.12, however I was able to reproduce this using python3.11.
Let me know in case I made a mistake in following the provided steps. From what I can tell, the steps are:
firebase init functions --project <project_id>cd functionspython3.11 -m venv venv. venv/bin/activate && python3.11 -m pip install -r requirements.txtmain.pyfirebase emulators:startIt does seem like the issue here is that
firebase-toolstries to find the latest version of python(currently 3.12). Setting theruntimeas mentioned in #6774 (comment) fixes the issue.Let me raise this issue to our engineering team so that we can determine the appropriate action for this. Also, feel free to make a PR for this if you’re up for it! Contributions are always welcome.
curtis-jotson commentedon Feb 20, 2024
@kmsbernard That's awesome, thanks! We're going to set this and see how it behaves.
@aalej Thanks for looking into this, my steps to reproduce might have been a bit off as we're mainly getting this issue on a Github Actions runner that has at least 6 different Python versions vs a local environment that we have more control over. Some is local in the case of the emulators, some is the runner in the case of the error using Python 3.12 instead of 3.11.
It all stems from not having the
runtimeoption configured infirebase.json. I think maybe another question is "Shouldfirebase init functionsbe initializing theruntimeoption?" In my "ignorant Firebase noob" world, the answer to that question is "Yes, it should initialize to the latest version the platform supports." As it stands right now, I didn't even realize it wasn't set andfirebase-toolswas trying to reason about it. If it were set by default (or even erroring if not specified), the necessity of reasoning about it is basically eliminated and it becomes the responsibility of the user to make sure it's set correctly.exaby73 commentedon Mar 8, 2024
Hello. I can reproduce this issue with Python 3.11 as well. Adding a runtime does fix it, however my LSP does warn me of a unknown value. I'm guessing the schema for
firebase.jsonis not updated.LSP warning in JSON:
Value is not accepted. Valid values: "nodejs10", "nodejs12", "nodejs14", "nodejs16", "nodejs18", "nodejs20".Strengthen typing of Runtimes+Langauges and their support timelines.
Strengthen typing of Runtimes+Langauges and their support timelines.
Strengthen typing of Runtimes+Langauges and their support timelines. (#…
Marco-Voegeli commentedon May 16, 2025
Hello. This issue is still current and the fix proposed by
Just a heads up:
Firebase's latest release (v14.4.0) now defaults with python3.13.
Using the quoted solution (adding the "runtime" variable with your python version (e.g. 312) patches this issue). Updating the codebase to something more future-proof could be nice 👍