Thu 08 October 2026

Brython Offline Interactive Shell and File Editor

Posted by Al Sweigart in misc   

Brython Offline is a single .html file that contains Brython, the browser-based Python interpreter, and a simple tabbed file editor. Now to do basic Python exercises you don't need to install Python, just open this one html file in a browser. No ads. No registration. No subscription. You can right-click and save the page and own it forever.

Just download and open brython-3.14.3-offline.html in a web browser and enter Python instructions into the interactive shell.

There are certain limitations: you can't access the file system or open files for reading and writing. The time.sleep() function doesn't work in JavaScript's single threaded environment. However, you can affect the DOM through Python code. See the Brython documentation for more info.

What is Brython?

Brython is an implementation of Python 3 that runs directly in a web browser.

Instead of writing JavaScript for browser behavior, you can write Python. Brython translates/executes that Python using JavaScript so it can interact with the page, DOM, events, and browser APIs.

Example:

<script type="text/python">
from browser import document

def hello(event):
    document["output"].text = "Hello from Python"

document["button"].bind("click", hello)
</script>

It is mainly useful for browser scripting and educational projects. It is not CPython running in the browser, so compatibility with Python packages—especially packages with native extensions—is much more limited than with Pyodide.

What's the difference between Brython and Pyodide?

Brython Pyodide
Core approach Implements Python in JavaScript Compiles CPython to WebAssembly
Compatibility Python-like, but not full CPython compatibility Very close to normal CPython
Python packages Limited; many CPython packages won't work Supports many packages, including NumPy, pandas, SciPy, etc.
Browser/DOM integration Very direct and convenient Available, but somewhat more explicit
Startup/download size Usually smaller/lighter Larger runtime
Performance Good for browser scripting Better suited to computational Python
Native extensions Generally unsupported Many packages are precompiled to WebAssembly
Best use Replacing JavaScript with Python for frontend logic Running real Python/data-science code in the browser

Check out other books by Al Sweigart, free online or available for purchase:

...and other books as well! Or register for the online video course. You can also donate to or support the author directly.