0.0.46 • Published 4 months ago

py_sandpack v0.0.46

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

PySandpack

PySandpack is a React library designed to provide a sandbox environment for executing Python code directly in the browser. It is ideal for educational purposes, quick experiments, or running Python scripts without requiring a local Python installation.

Visit PySandbox to see what PySandpack can do!

Features

  • Run Python Code in Your Browser
    Powered by Pyodide, PySandpack allows users to execute Python scripts in a safe and isolated environment.

  • Code Editor with Rich Features
    The integrated CodeMirror editor offers syntax highlighting, auto-indentation, and a clean interface for writing Python code.

Getting Started

1. Using Code/Preview split component

import PySandpack from "py_sandpack";

<PySandpack codes={{ "main.py": "print('Hello, World!')" }} lang="python" />;

2. Using Preview only

import { PySandpackPreview, PySandpackProvider, usePySandpack } from 'py_sandpack';

function PreviewComponent() {
    const pySandpack = usePySandpack();

    React.useEffect(() => {
        pySandpack.isReady && pySandpack.runCodes();
    }, [pySandpack.isReady, pySandpack.codes]);

    return (
        <PySandpackPreview />
    )
}

function YourComponent() {
    return (
        <PySandpackProvider codes={{ "main.py": "print('Hello,World!')" }} lang="python">
            <PreviewComponent />
        </PySandpackProvider>
    )
}

Technology Stack

  • CodeMirror: A versatile text editor for the web, providing an intuitive and developer-friendly experience.
  • Pyodide: A Python distribution for the browser, enabling Python code execution using WebAssembly.

Logo Image Source

0.0.46

4 months ago

0.0.45

5 months ago

0.0.44

5 months ago

0.0.43

6 months ago

0.0.42

6 months ago

0.0.41

7 months ago

0.0.40

7 months ago

0.0.39

7 months ago

0.0.38

7 months ago

0.0.37

7 months ago

0.0.36

7 months ago

0.0.35

7 months ago

0.0.34

7 months ago

0.0.33

7 months ago

0.0.32

7 months ago

0.0.31

7 months ago

0.0.30

7 months ago

0.0.29

7 months ago

0.0.28

7 months ago

0.0.27

7 months ago

0.0.26

7 months ago

0.0.25

7 months ago

0.0.24

7 months ago

0.0.23

7 months ago

0.0.22

7 months ago

0.0.21

7 months ago

0.0.20

7 months ago

0.0.19

7 months ago

0.0.18

7 months ago

0.0.17

7 months ago

0.0.16

7 months ago

0.0.15

7 months ago

0.0.14

7 months ago

0.0.13

7 months ago

0.0.12

7 months ago

0.0.11

7 months ago

0.0.10

7 months ago

0.0.9

7 months ago

0.0.8

7 months ago

0.0.7

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago