Run Python Directly in the Browser with PyScript: A Quick Introduction
PyScript, announced by the creators of Anaconda, is a browser‑based Python framework that lets developers embed Python code in standard HTML, call JavaScript libraries, manage environments, and build interactive web applications using familiar Python packages.
Known Python distribution Anaconda’s developers recently announced PyScript, a framework that enables Python to run directly in the browser.
According to the official description, PyScript provides developers the ability to embed Python code in standard HTML, call JavaScript libraries from Python, and create Python web applications. It aims to treat Python as a first‑class language with consistent styling rules, expressive syntax, and an easy learning curve.
PyScript Example Code
<py-script>Hello World</py-script> <py-script src="/my_own_file.py"></py-script> <py-env>
- bokeh
- numpy
- paths:
- /utils.py
</py-env>Core Features
Python in the browser: drop‑in content, external file hosting (based on Pyodide), and no server‑side configuration required.
Python ecosystem: includes popular scientific packages such as numpy, pandas, scikit‑learn, etc.
Python with JavaScript: bidirectional communication between Python and JavaScript objects and namespaces.
Environment management: developers can specify which packages and files to include for page execution.
Visual application development: ready‑made UI components like buttons, containers, and text fields are available.
Flexible framework: allows creation and sharing of new plug‑in and extensible components directly in Python.
Goals
Provide a clean, simple API.
Support standard HTML.
Extend HTML to read stable, reliable custom components.
Offer a pluggable, extensible component system.
PyScript is built on Pyodide, which consists of a WebAssembly‑compiled CPython 3.8 interpreter that runs Python in the browser. Pyodide can install any package from PyPI and includes an external function interface to expose Python packages to JavaScript and the browser UI (including the DOM) to Python.
For more details on how PyScript works, see the engineering blog at https://engineering.anaconda.com/2022/04/welcome-pyscript.html .
PyScript is currently in alpha testing; it can be downloaded from https://pyscript.net/ .
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
