Run Python in a browser: files, packages and limits
Choose between local WebAssembly execution and a hosted Python runtime, and prepare a small reproducible script before sharing it.
Identify where the code runs
A browser Python environment may run Python through WebAssembly on your device, or send code to a remote server. The distinction affects privacy, supported packages, network access and persistence. Pyodide is a browser-capable Python distribution; its documentation lists supported packages and browser limitations. Dev Bench does not currently host a Python runtime, so this page is a selection and troubleshooting guide.
Prepare a minimal script
Start with a short script that uses only the standard library and prints a clear result. Then add file input and dependencies one at a time. A package available on desktop Python is not automatically compatible with a browser build, particularly when it requires native extensions, operating-system processes or unrestricted sockets. Record the runtime version and package versions alongside the script.
Treat uploaded files as temporary unless documented
A file selected from your computer is not necessarily saved into a persistent filesystem. Reloading, clearing storage or closing a private window may remove the working environment. Export your source and output explicitly. In a hosted environment, check the provider’s storage and sharing behaviour before uploading sensitive data. A public notebook link can expose code, outputs and embedded credentials.
Diagnose performance and sharing problems
The first launch may download a substantial runtime, so test on the network and device you expect readers to use. Long synchronous calculations can freeze a browser interface unless moved into a worker. Do not include API secrets in code sent to a browser. A reproducible example should contain a small synthetic input, exact run instructions and the expected output, so another person can verify the problem without your original files.