0.0.46 • Published 7 months ago

py_sandpack v0.0.46

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

7 months ago

0.0.45

7 months ago

0.0.44

8 months ago

0.0.43

9 months ago

0.0.42

9 months ago

0.0.41

9 months ago

0.0.40

9 months ago

0.0.39

9 months ago

0.0.38

9 months ago

0.0.37

9 months ago

0.0.36

9 months ago

0.0.35

9 months ago

0.0.34

9 months ago

0.0.33

9 months ago

0.0.32

9 months ago

0.0.31

9 months ago

0.0.30

9 months ago

0.0.29

9 months ago

0.0.28

9 months ago

0.0.27

9 months ago

0.0.26

9 months ago

0.0.25

9 months ago

0.0.24

9 months ago

0.0.23

9 months ago

0.0.22

9 months ago

0.0.21

9 months ago

0.0.20

9 months ago

0.0.19

9 months ago

0.0.18

9 months ago

0.0.17

9 months ago

0.0.16

9 months ago

0.0.15

9 months ago

0.0.14

9 months ago

0.0.13

9 months ago

0.0.12

9 months ago

0.0.11

9 months ago

0.0.10

9 months ago

0.0.9

9 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago