- Notifications
You must be signed in to change notification settings - Fork3
An embeddable Python REPL, powered by Pyodide
License
savannahostrowski/pyrepl-web
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
An embeddable Python REPL, powered by Pyodide.
Include the script and use the<py-repl> web component:
<scriptsrc="https://cdn.jsdelivr.net/npm/pyrepl-web/dist/pyrepl.js"></script><py-repl></py-repl>
That's it! No install needed.
- Python 3.13 in the browser via WebAssembly (Pyodide)
- Syntax highlighting powered by Pygments
- Tab completion for modules, functions, and variables
- Command history with up/down arrows
- Smart indentation for multi-line code
- Keyboard shortcuts: Ctrl+L (clear), Ctrl+C (cancel)
- PyPI packages: preload popular libraries
- Startup scripts: run Python on load to set up the environment
- Theming: built-in dark/light themes or fully custom
| Attribute | Description | Default |
|---|---|---|
theme | Color theme name (builtin or registered viawindow.pyreplThemes) | catppuccin-mocha |
packages | Comma-separated list of PyPI packages to preload | none |
repl-title | Custom title in the header bar | Python REPL |
src | Path to a Python startup script (see below) | none |
no-header | Hide the header bar (boolean attribute) | not set |
no-buttons | Hide copy/clear buttons in header (boolean attribute) | not set |
readonly | Disable input, display only (boolean attribute) | not set |
no-banner | Hide the "Python 3.13" startup banner (boolean attribute) | not set |
Usesrc to preload a Python script that sets up the environment:
<py-replsrc="/scripts/setup.py"packages="pandas"></py-repl>
The script runs silently to populate the namespace. If you define asetup() function, it will be called after loading and its output is visible in the terminal:
# setup.pyimportpandasaspddf=pd.DataFrame({'name': ['Alice','Bob'],'age': [30,25]})defsetup():print("DataFrame loaded:")print(df)
Built-in themes:catppuccin-mocha (dark, default) andcatppuccin-latte (light).
Register custom themes viawindow.pyreplThemes before loading the script. Onlybackground andforeground are required - everything else is automatically derived:
<script>window.pyreplThemes={'my-theme':{background:'#1a1b26',foreground:'#a9b1d6',}};</script><scriptsrc="https://cdn.jsdelivr.net/npm/pyrepl-web/dist/pyrepl.js"></script><py-repltheme="my-theme"></py-repl>
What gets auto-derived from your background color:
- Terminal colors (red for errors, green for success, etc.) - from catppuccin-mocha (dark) or catppuccin-latte (light)
- Syntax highlighting - uses the matching catppuccin Pygments style
- Header colors - derived from the base theme
| Property | Description |
|---|---|
background | Terminal background color (required) |
foreground | Default text color (required) |
headerBackground | Header bar background (optional) |
headerForeground | Header title color (optional) |
promptColor | Prompt>>> color - hex (#7aa2f7) or name (green,cyan) (optional) |
pygmentsStyle | Custom syntax highlighting (optional, see below) |
Syntax highlighting usesPygments. The style is chosen automatically:
- If your theme name matches aPygments style (e.g.,
monokai,dracula), that style is used - Otherwise, uses
catppuccin-mochafor dark backgrounds orcatppuccin-lattefor light backgrounds
For full control, provide apygmentsStyle mappingPygments tokens to colors:
<script>window.pyreplThemes={'tokyo-night':{background:'#1a1b26',foreground:'#a9b1d6',promptColor:'#bb9af7',pygmentsStyle:{'Keyword':'#bb9af7','String':'#9ece6a','Number':'#ff9e64','Comment':'#565f89','Name.Function':'#7aa2f7','Name.Builtin':'#7dcfff',}}};</script>
About
An embeddable Python REPL, powered by Pyodide
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors2
Uh oh!
There was an error while loading.Please reload this page.