Python in the Playground
Python files in the Playground really run, with Qiskit, Aer, numpy, pandas and matplotlib. Each run happens in a fresh, isolated sandbox on the server that has no network, no files and no secrets.
How a run works
- Press Run file (Ctrl/Cmd+Enter). The file goes to the server and starts in a new sandbox process; nothing is shared with other runs or other people.
- print() output, figures from plt.show(), tables and results appear in the Output panel in the order your program made them.
- Like a notebook, a value on the last line is shown: a circuit as its drawing, a DataFrame as a table, counts as a chart, a Statevector as its amplitudes. show(obj) does the same anywhere in the file.
- Each tab keeps its own output; two files can run at once and the rest wait in a queue.
Available modules
| Module | Version | Use it for |
|---|---|---|
| qiskit | 2.6.1 | Circuits, transpile, quantum_info, circuit.library, visualization |
| qiskit_aer | 0.18.0 | AerSimulator: shots, statevectors, noise models |
| numpy | 2.5.4 | Arrays and linear algebra |
| pandas | 3.0.6 | Tables (DataFrame, Series), describe(), CSV from text |
| matplotlib | 3.11.2 | Charts with pyplot (shown with plt.show()) |
| scipy | 1.18.1 | Optimisation, linear algebra, statistics |
| sympy | 1.14.0 | Symbolic maths |
| seaborn | 0.13.2 | Statistical charts on top of matplotlib |
| Standard library | 3.12 | math, cmath, random, statistics, fractions, decimal, itertools, functools, collections, heapq, bisect, operator, re, string, textwrap, json, csv, io (StringIO, BytesIO), datetime, time, typing, dataclasses, enum, copy, abc, numbers |
The Playground also lists these with their exact versions: open a Python file before running it, or use Show all under a refused import.
Files, folders and imports
A Python run can use the other files in your Playground: import functions from your own .py files, and read CSV, text, JSON or .qasm files. The files go with the run in memory and are read-only; nothing is saved on the server.
from helpers.circuits import bell # helpers/circuits.py
import pandas as pd
angles = pd.read_csv("data/angles.csv")
with open("data/notes.txt") as f:
print(f.read())
from qiskit import qasm3
qc = qasm3.loads(open("dynamic/teleportation.qasm").read())- Click the light bulb in the Files panel to add a working example: helpers/circuits.py, data/angles.csv, data/notes.txt and examples/use-files.py. Your own files are not changed.
- The editor suggests as you type: folders and modules after from or import, def, class and variable names after import or after mod., and folders and files inside open("…") or pd.read_csv("…"). Press Ctrl+Space to ask for suggestions.
- New files ending in .csv, .tsv, .txt, .json, .md or .dat are data files: Python reads them, they have no Run button.
- Up to 200 files and 1 MB in total go with each run. Paths outside the Playground, such as /etc or ../, are refused.
What is refused, and what to do instead
| You tried | Why | Try instead |
|---|---|---|
| import os, sys, subprocess | No access to the server, its files or its environment | Build data in the code and print() it |
| open("/etc/passwd"), open("../x"), writing a file | Only your own Playground files can be opened, and only for reading | Add the file to the Playground and open it by its path, e.g. data/angles.csv |
| requests, urllib, socket | The network is switched off | Put the data you need in the code |
| eval, exec, compile, __import__, __subclasses__ | Running code built from text or reaching Python's internals is turned off | Write the code directly |
| pennylane, cirq | Not installed | qiskit: QubitLab runs Qiskit circuits and OpenQASM 3 |
| sklearn, torch, tensorflow | Not installed | numpy or scipy for small examples |
| plotly, bokeh | Not installed | matplotlib (or seaborn) |
Limits per run
- 10 seconds of running time (an endless loop is stopped with a message).
- About 1 GB of address space; the libraries alone use about 200 MB.
- 100 KB of printed text, 20 figures, 2 MB per figure, 10,000 rows per table (100 are shown), 200 KB of code.
- 20 runs per minute per account. When a limit is reached the output says so; nothing fails silently.
How the sandbox keeps everyone safe
Isolation comes first: every run is a new process inside bubblewrap with no network, a read-only system, an empty temporary folder and no environment secrets, so code cannot reach other runs, the server or the internet. Inside it, Python has extra guards: an import allowlist, built-ins such as open and eval removed, and an audit hook that refuses files, sockets, processes and unpickling. Your code and its output are not logged.
The IDE's code panel is different: there Python is only translated to OpenQASM 3 by reading its syntax, and the circuit is what runs.