Frequently asked questions

Syntax, keywords and built-in functions

Standard distribution

import implementation

Browser interface

Brython-specific built-in modules

Working with Brython

Brython for Firefox OS



First installation

To install Brython :

  • if your PC has CPython and pip, install the package brython by

    pip install brython

then in an empty directory run

    python -m brython --install

  • if you can't use this method, go to the releases page on Github, select the latest version, download and unzip

In both cases the directory has the following files :

  • brython.js : the Brython engine, to include in the HTML page
  • brython_stdlib.js : groups all the modules and packages of the part of the Python standard library supported by Brython
  • demo.html : a page with a few examples of how to use Brython for client-side development

brython.js includes very often used modules : browser, browser.html, javascript.

If your application uses modules of the standard distribution, you need to include brython_stdlib.js besides brython.js:

<script type="text/javascript" src="brython.js"></script>
<script type="text/javascript" src="brython_stdlib.js"></script>


When a new version of Brython is published, the update is done by the usual command:

pip install brython --upgrade

In the application directory, you can then update the Brython files (brython.js et brython_stdlib.js) by:

python -m brython --update

Web server

The HTML files can be opened in the browser, but it is recommended to start a web server in the application directory.

The most straightforward is to use the module http.server in CPython standard distribution:

python -m http.server

The default port is 8000. To choose another port:

python -m http.server 8001

You can then access the pages by entering http://localhost:8001/demo.html in the browser address bar.