0.0.46 • Published 5 months ago

py_sandpack v0.0.46

Weekly downloads
-
License
MIT
Repository
github
Last release
5 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

5 months ago

0.0.45

6 months ago

0.0.44

6 months ago

0.0.43

8 months ago

0.0.42

8 months ago

0.0.41

8 months ago

0.0.40

8 months ago

0.0.39

8 months ago

0.0.38

8 months ago

0.0.37

8 months ago

0.0.36

8 months ago

0.0.35

8 months ago

0.0.34

8 months ago

0.0.33

8 months ago

0.0.32

8 months ago

0.0.31

8 months ago

0.0.30

8 months ago

0.0.29

8 months ago

0.0.28

8 months ago

0.0.27

8 months ago

0.0.26

8 months ago

0.0.25

8 months ago

0.0.24

8 months ago

0.0.23

8 months ago

0.0.22

8 months ago

0.0.21

8 months ago

0.0.20

8 months ago

0.0.19

8 months ago

0.0.18

8 months ago

0.0.17

8 months ago

0.0.16

8 months ago

0.0.15

8 months ago

0.0.14

8 months ago

0.0.13

8 months ago

0.0.12

8 months ago

0.0.11

8 months ago

0.0.10

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago