Skip to main content
0 reactions

Fixed: “SyntaxWarning: ‘return’ in a ‘finally’ block” in Rasa Pro on Python 3.14

Card titled SyntaxWarning on Python 3.14, with a warning sign and two notes: shown by Python 3.14, and harmless, first run only.
SyntaxWarning in Rasa Pro on Python 3.14: harmless, first run only.

The first time you run Rasa Pro 3.21 on Python 3.14, two warnings appear before the output: SyntaxWarning: 'return' in a 'finally' block. They’re harmless. They come from Sanic, a web library that Rasa Pro installs, and they appear only once. Here’s what happened, and why you can ignore them.

What I Was Doing

I was installing Rasa Pro 3.21.4 on a Mac with Python 3.14.10, following Installing Rasa Pro: Setting Up Your Development Environment. Its last step runs rasa --version for the first time.

What I Expected

Rasa’s version details, and nothing else.

What I Got

Two warnings came first, then the version details:

Output (the lines that matter)Plain text
/Users/user/my-rasa-agent/.venv/lib/python3.14/site-packages/sanic/server/websockets/impl.py:437: SyntaxWarning: 'return' in a 'finally' block
  return
/Users/user/my-rasa-agent/.venv/lib/python3.14/site-packages/sanic/server/websockets/impl.py:463: SyntaxWarning: 'return' in a 'finally' block
  return
Rasa Pro Version  :         3.21.4
A Terminal window after running rasa --version: two SyntaxWarning lines about a return in a finally block in Sanic’s impl.py, followed by the version details for Rasa Pro 3.21.4 and Python 3.14.10.
The first run: two SyntaxWarning lines, then the version details.

This first run also took about 40 seconds. Rasa still printed its version details, so the command worked.

What I Checked

  • Where it comes from: each warning points to sanic/server/websockets/impl.py, inside the virtual environment. Sanic is a web framework that Rasa Pro installs. The version here, 25.12.1, is the newest on PyPI (opens in a new tab), and the one Rasa Pro 3.21 requires.
  • What Python says: What’s New in Python 3.14 (opens in a new tab) explains that since Python 3.14, the compiler warns when a return, break or continue leaves a finally block (PEP 765). It’s a warning, not an error.
  • When it shows: the compiler warns while it compiles a file. Python saves each compiled file and reuses it on later runs (Python’s tutorial (opens in a new tab)).

Why It Happens

Two lines in Sanic’s code use return inside a finally block, a pattern Python 3.14 now warns about. Python compiles each library file the first time it’s used and saves the result, so the warning appears on the first run only. It’s about how Sanic’s code is written, not about your project, and it doesn’t stop Rasa Pro.

The Fix

There’s nothing to change. Run the same command again:

TerminalBash
rasa --version

Python now uses the compiled files it saved, so the warnings don’t come back. They appear again only in a new virtual environment, on its first run.

After the Fix

The second run printed only the version details, in about 5 seconds:

Output (the lines that matter)Plain text
Rasa Pro Version  :         3.21.4
Minimum Compatible Version: 3.20.0
Rasa SDK Version  :         3.21.2
Python Version    :         3.14.10
Operating System  :         macOS-26.7.3-arm64-arm-64bit-Mach-O
A Terminal window after running rasa --version again: only the version details for Rasa Pro 3.21.4 and Python 3.14.10, with no warnings.
The second run: no warnings.

Common Mistakes

MistakeDo this instead
Taking the warnings for a failed installLook below them: the version details mean Rasa Pro works.
Switching to an older Python to avoid themNot needed. Rasa Pro 3.21 supports Python 3.14.
Editing Sanic’s files inside .venvLeave them as they are. Reinstalling replaces them anyway.

FAQ

Is the SyntaxWarning dangerous?

No. It’s about how two lines in Sanic are written. Rasa Pro runs normally.

Why does it appear only once?

Python saves each compiled file in a __pycache__ folder and reuses it, so it doesn’t compile the file, or warn, again.

Does it appear on Python 3.13?

No. This warning is new in Python 3.14.

Can I hide it completely?

Python’s docs show a warning filter for that, ignore::SyntaxWarning. Since the warning shows only once, you don’t need it.

Conclusion

The SyntaxWarning: 'return' in a 'finally' block lines come from Sanic and Python 3.14’s new check, not from Rasa or your project. Run the command again, and they’re gone.

Additional Resources

Rasa and other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with or endorsed by Rasa Technologies.

0 comments