Brython

What Brython is
Brython implements Python 3 for interactive web applications that run inside HTML pages. Python code can access browser pages through the DOM using the browser module’s document and window objects, while browser.html exposes HTML tags as Python classes. Examples cover changing page elements, handling events, graphics, animations, Ajax requests, and local file selection. The browser.aio module supports asynchronous programming with async and await. Brython can be loaded from jsDelivr or cdnjs without installation, or installed locally with pip or a release archive. Compatible CPython packages can be added with brython-cli add_package, and Brython packages can bundle importable modules for hosting on any server. Browser restrictions limit network requests and file access: the documented Python file interface cannot write, and reads are limited to files reachable through Ajax. Packages relying on C extensions, including NumPy, Matplotlib, and Pandas, are not supported. The FAQ says it supports modern browsers, including smartphone browsers. Brython is free and open source, and applications can be uploaded to a server or packaged for PyPI distribution.
Who it suits
It suits Python developers building browser-based interactive pages who can work within browser networking and file-access limits. It may not fit projects that depend on C-extension packages such as NumPy, Matplotlib, or Pandas.
What it does well
- Uses Python 3 in HTML pages.
- Provides DOM access through document and window.
- Supports async and await through browser.aio.
- Can load from jsDelivr or cdnjs without installation.
- Compatible packages can be added with brython-cli.
What to know first
- Cannot use CPython packages that rely on C extensions.
- Browser limits prevent file writing through its Python interface.
- Network requests are restricted by browser rules.
Limits
Brython cannot use CPython packages that rely on C-written extensions, including NumPy, Matplotlib, and Pandas. Browser restrictions constrain network requests, and file reading is limited to files reachable through Ajax; the documented Python file interface cannot write files.
Getting started
- Load Brython from jsDelivr or cdnjs without installing it.
- Alternatively, install it locally with pip or a downloadable release archive.
- Add compatible pip-installed CPython packages with brython-cli add_package.
- Build the application using Brython’s browser modules and HTML page.
- Upload the application directory to a server or package it for PyPI distribution.
Verdict
Brython brings Python syntax and browser APIs together for interactive web pages, with several ways to load or deploy applications. Browser security constraints and the exclusion of C-extension packages define important limits.
Questions
Is Brython free?
Yes. Brython is free and open source.
Which platforms does Brython support?
The listed platforms are Android, iOS, self-hosted, and web. Its FAQ says it supports modern browsers, including smartphone browsers.
Can Brython use Python packages?
It includes part of the CPython standard library and can install compatible Python packages. Packages that rely on C extensions are excluded.
Can Python code make network requests in Brython?
Browser code can make Ajax requests to its own domain and to sites that support cross-origin requests. Browser restrictions prevent arbitrary requests to any URL.
How can I install or deploy Brython?
Load it from jsDelivr or cdnjs without installation, or install locally with pip or a release archive. Applications can be uploaded to a server or packaged for PyPI.
Facts from Brython's own pages
- Async programming
- The CPython asyncio module is not usable in Brython; the documentation provides the Brython-specific browser.aio module instead. · brython.info, 8 Oct 2026
- Browser features
- Its examples cover creating and modifying page elements, events, graphics, animations, Ajax requests, and local file selection. · brython.info, 8 Oct 2026
- Browser file limits
- The browser environment prevents file writing, and file reading is limited to files accessible through Ajax requests. · brython.info, 8 Oct 2026
- Browser support
- The FAQ says Brython supports all modern browsers, including browsers on smartphones. · brython.info, 8 Oct 2026
- Deployment
- A Brython application can be deployed by uploading its directory to a server or packaged for distribution through PyPI. · brython.info, 8 Oct 2026
- Distribution
- Brython packages bundle importable modules in .brython.js files that can be hosted on any server. · brython.info, 8 Oct 2026
- DOM interface
- Brython provides browser-facing modules for working with the DOM, including document and window. · brython.info, 8 Oct 2026
- DOM support
- Brython provides access to browser pages through the DOM using the browser module's document and window objects. · brython.info, 8 Oct 2026
- File access limits
- Browser file access is constrained: writing is impossible through the documented Python file interface, and reading is limited to files reachable by Ajax requests. · brython.info, 8 Oct 2026
- HTML elements
- The browser.html module exposes HTML4, HTML5, and some HTML5.1 tags as Python classes. · brython.info, 8 Oct 2026
- Installation
- Brython can be used from jsDelivr or cdnjs without installation, or installed locally with pip or a GitHub release archive. · brython.info, 8 Oct 2026
- Install options
- Brython can be loaded from jsDelivr or cdnjs without installation, or installed locally with pip or a downloadable release. · brython.info, 8 Oct 2026
- Integrations
- A CPython package installed with pip can be added to a Brython application with brython-cli add_package. · brython.info, 8 Oct 2026
- JavaScript interoperability
- Brython provides ways for Python code to use JavaScript objects and libraries. · brython.info, 8 Oct 2026
- Network limitations
- Browser code can make Ajax requests to its own domain and to sites that support cross-origin requests; the FAQ gives requests as an incompatible example. · brython.info, 8 Oct 2026
- Package limitations
- The FAQ says Brython cannot use CPython packages that rely on C extensions, naming NumPy, Matplotlib, and Pandas as examples. · brython.info, 8 Oct 2026
- Package limits
- Brython runs Python programs, not programs written in C, so numpy and data science packages that rely on it will not work. · brython.info, 8 Oct 2026
- Purpose
- Brython implements Python 3 in the browser and lets developers run Python code in HTML pages. · brython.info, 8 Oct 2026
- Python syntax
- Brython supports the keywords and functions of the corresponding Python version, subject to browser and JavaScript limitations. · brython.info, 8 Oct 2026
- Security and compliance
- The official pages reviewed provide no stated security certification or compliance claim. · brython.info, 8 Oct 2026
- Security constraints
- Browser restrictions limit HTTP requests; packages such as requests and urllib.request cannot send arbitrary requests to any URL. · brython.info, 8 Oct 2026
- Supported library
- Brython includes part of the CPython standard library and can install compatible Python packages, but packages containing C-written files are excluded. · brython.info, 8 Oct 2026
Where Brython stands on Freedom251
- Code Transpilers#5 of 28