Get started with pyodide CDN

Apache-2.0 licensed

Pyodide is a library that enables running Python scientific and data science libraries in the browser without needing a local Python installation.

Tags:
  • python
  • webassembly

Stable version

Copied!

How to start using pyodide CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with pyodide CDN - cdnhub.io</title>
    <script src="https://cdn.jsdelivr.net/npm/pyodide@0.25.0/full/pyodide.js"></script>
    <script>
        async function main() {
            await loadPyodide();

            const py = await pyodide;
            const np = py.numpy;

            // Create a NumPy array
            const arr = np.array([1, 2, 3, 4, 5]);

            // Print the NumPy array
            console.log(arr);

            // Perform some simple NumPy operations
            const squared = np.square(arr);
            const sum = np.sum(arr);

            console.log('Squared:', squared);
            console.log('Sum:', sum);
        }

        main();
    </script>
</head>
<body>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions