QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
HomeLearnCatalogRanksPlaygroundDocs
  1. Docs
  2. Python in the Playground
Learn
  • Quantum basics
  • OpenQASM 3 cheat sheet
  • All gates, with the math
  • Every gate, interactive
  • Entanglement: how CNOT connects qubits
Circuits
  • Dynamic circuits: if/else, loops and conditions
Lessons
  • Learning path: from one qubit to algorithms
  • Quantum machine learning by hand
Run
  • Compile (transpile): levels, basis gates, topology
  • Simulators, noise, T1/T2 and fake backends
  • Python in the Playground
  • GitHub and git in the Playground
  • Articles and sharing
Analyze
  • Metrics: comparing distributions
  • Q-sphere and Bloch spheres
Hardware
  • Real IBM Quantum hardware
  • Device topology and calibration heat maps
  • Benchmark circuits: MQT Bench and QASMBench
Advanced
  • Circuit cutting, in depth
Story
  • The story of quantum computing
  • The Hamiltonian: where gates come from
  • What to expect next
Documentation/Run/Python in the Playground

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

ModuleVersionUse it for
qiskit2.6.1Circuits, transpile, quantum_info, circuit.library, visualization
qiskit_aer0.18.0AerSimulator: shots, statevectors, noise models
numpy2.5.4Arrays and linear algebra
pandas3.0.6Tables (DataFrame, Series), describe(), CSV from text
matplotlib3.11.2Charts with pyplot (shown with plt.show())
scipy1.18.1Optimisation, linear algebra, statistics
sympy1.14.0Symbolic maths
seaborn0.13.2Statistical charts on top of matplotlib
Standard library3.12math, 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())
Folders work like Python packages: helpers/circuits.py is imported as helpers.circuits. A path is looked up first next to the running file, then from the top of the Playground.
  • 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 triedWhyTry instead
import os, sys, subprocessNo access to the server, its files or its environmentBuild data in the code and print() it
open("/etc/passwd"), open("../x"), writing a fileOnly your own Playground files can be opened, and only for readingAdd the file to the Playground and open it by its path, e.g. data/angles.csv
requests, urllib, socketThe network is switched offPut the data you need in the code
eval, exec, compile, __import__, __subclasses__Running code built from text or reaching Python's internals is turned offWrite the code directly
pennylane, cirqNot installedqiskit: QubitLab runs Qiskit circuits and OpenQASM 3
sklearn, torch, tensorflowNot installednumpy or scipy for small examples
plotly, bokehNot installedmatplotlib (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.

← Previous
Simulators, noise, T1/T2 and fake backends
Next →
GitHub and git in the Playground
On this page
  • How a run works
  • Available modules
  • Files, folders and imports
  • What is refused, and what to do instead
  • Limits per run
  • How the sandbox keeps everyone safe
Try it in the IDE →
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in