Description
I have Python 3.13 installed.
% python3.13 --version
Python 3.13.1
I am trying to follow the guide at https://firebase.google.com/docs/functions/get-started?gen=2nd and run firebase functions with:
firebase init functions
...
firebase emulators:start
The emulator says either...
Failed to load function definition from source: FirebaseError: Failed to find location of Firebase Functions SDK:
Missing virtual environment at venv directory. Did you forget to run 'python3.12 -m venv venv'?
... or, if I run cd ./functions && python3 -m venv venv
...
Failed to load function definition from source: FirebaseError: Failed to find location of Firebase Functions SDK.
Did you forget to run '. "./functions/venv/bin/activate" && python3.12 -m pip install -r requirements.txt'?
I don't see that logged step documented anywhere.
Apparently you have to run the equivalent of:
pushd functions
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
deactivate
popd
firebase emulators:start
But that is all moot because it still fails!
Looking at firebase-debug.log
: EMPHASIS MINE
...
[info] i functions: Watching "/Users/pv/Dev/GitHub/swooby/swoo.by/functions" for Cloud Functions... {"metadata":{"emulator":{"name":"functions"},"message":"Watching \"/Users/pv/Dev/GitHub/swooby/swoo.by/functions\" for Cloud Functions..."}}
[debug] [2025-03-18T21:38:02.543Z] Customer code is not Node
[debug] [2025-03-18T21:38:02.543Z] Validating python source
[debug] [2025-03-18T21:38:02.543Z] Building python source
[debug] [2025-03-18T21:38:02.543Z] Could not find functions.yaml. Must use http discovery
*****
[debug] [2025-03-18T21:38:02.545Z] Running command with virtualenv: command=., args=["\"/Users/pv/Dev/GitHub/swooby/swoo.by/functions/venv/bin/activate\"","&&","python3.12","-c","\"import firebase_functions; import os; print(os.path.dirname(firebase_functions.__file__))\""]
[debug] [2025-03-18T21:38:02.553Z] stderr: /bin/sh: python3.12: command not found
*****
[error] ⬢ functions: Failed to load function definition from source: FirebaseError: Failed to find location of Firebase Functions SDK. Did you forget to run '. "/Users/pv/Dev/GitHub/swooby/swoo.by/functions/venv/bin/activate" && python3.12 -m pip install -r requirements.txt'? {"metadata":{"emulator":{"name":"functions"},"message":"Failed to load function definition from source: FirebaseError: Failed to find location of Firebase Functions SDK. Did you forget to run '. \"/Users/pv/Dev/GitHub/swooby/swoo.by/functions/venv/bin/activate\" && python3.12 -m pip install -r requirements.txt'?"}}
[debug] [2025-03-18T21:38:02.555Z] Could not find VSCode notification endpoint: FetchError: request to http://localhost:40001/vscode/notify failed, reason: . If you are not running the Firebase Data Connect VSCode extension, this is expected and not an issue.
...
The root cause is that python3.12
is trying to be used.
Again, I have Python 3.13.
I tried setting firebase.json
...
"functions": [
{
"runtime": "python313",
...
...but firebase emulators:start
fails with:
% firebase emulators:start
(node:78311) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
i emulators: Starting emulators: functions, hosting, extensions
⚠ hosting: Port 6000 is restricted by some web browsers, including Chrome. You may want to choose a different port such as 6001.
i emulators: Shutting down emulators.
i hub: Stopping emulator hub
Error: Cannot load functions from ./functions because it has invalid runtime python313
Looking at https://github.com/firebase/firebase-tools/blob/master/src/deploy/functions/runtimes/python/index.ts
export function getPythonBinary(
runtime: supported.Runtime & supported.RuntimeOf<"python">,
): string {
if (process.platform === "win32") {
// There is no easy way to get specific version of python executable in Windows.
return "python.exe";
}
if (runtime === "python310") {
return "python3.10";
} else if (runtime === "python311") {
return "python3.11";
} else if (runtime === "python312") {
return "python3.12";
}
assertExhaustive(runtime, `Unhandled python runtime ${runtime as string}`);
}
This code tells me that Python 3.13 (python313
) released 2024-10-07 is not supported?!?!
Where is/are the required/supported python version numbers listed?
Why does specifying an existing valid "runtime": "python313"
fail?
Why does defaulting to or specifying a not existing "runtime": "python312"
not fail?
This is all a pretty big cluster F.
Wasn't this supposed to be fixed by #6866 ?
[REQUIRED] Environment info
firebase-tools: 13.34.0
Platform: macOS (I do not think this is macOS specific)
[REQUIRED] Test case
?
[REQUIRED] Steps to reproduce
- Install Python 3.13 only (do not have any other Python 3 or 2 version installed).
- Follow https://firebase.google.com/docs/functions/get-started?gen=2nd
firebase init functions
- Init functions to use Python
- VERY FRUSTRATINGLY, nothing in the documentation says that it seems like the following additional steps are required?:
pushd functions
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
deactivate
popd
firebase emulators:start
[REQUIRED] Expected behavior
- firebase emulator functions work successfully
[REQUIRED] Actual behavior
- firebase emulator starts [false] successfully
- debug log says it failed to find python 3.12
- emulator functions page says
Failed to load function definition from source: FirebaseError: Failed to find location of Firebase Functions SDK. Did you forget to run '. "./functions/venv/bin/activate" && python3.12 -m pip install -r requirements.txt'?
WORKAROUND
Install Python 3.12, but that is a pretty sad/weak workaround.