[Python] Python in browser with WebAssembly without recompilation

Discussão em 'Python' iniciado por Stack, Abril 1, 2025.

  1. Stack

    Stack Membro Participativo

    I've looked at Compiling Python to WebAssembly, and its various answers, various projects (EmPython, EmCPython, cpython-emscripten, Pyodide, etc.) but most of the time, it requires recompilation or using Docker, etc.

    Is there a way to use Python in the browser (with WebAssembly), such that it works like this:


    • You simply put foo.js, foo.wasm, index.html, or similar ready-to-use files in a directory


    • You put a main.py file in the directory, that the WebAssembly Python interepreter automatically starts when we open index.html in the browser, and Python stdout is directly displayed in the browser


    • You can import standard Python modules by simply adding the .py files along main.py

    Example:

    pythoninbrowser.js
    pythoninbrowser.wasm
    index.html
    main.py --> containing "import bs4"
    bs4/
    __init__.py
    ...all the rest of the BeautifulSoup module...


    See also this issue.

    Continue reading...

Compartilhe esta Página