This Qiskit tutorial for beginners walks through a complete first experiment: install the core packages, create a circuit, apply gates, measure qubits, run the circuit on a local simulator, and prepare for execution through IBM Quantum. Use the checklists and reusable code template to troubleshoot your setup and build the next circuit with confidence.
Overview
Qiskit is a Python-based framework for writing and running quantum programs. A typical workflow has five parts:
- Define the circuit: Create qubits and classical bits, or use measurement helpers that add them for you.
- Apply operations: Add quantum gates such as Hadamard, Pauli-X, and controlled-NOT gates.
- Measure: Convert quantum states into classical results.
- Choose a backend: Run locally with a simulator or submit to a compatible remote quantum service.
- Inspect results: Review counts, metadata, circuit drawings, and any transpilation changes.
The example below creates a two-qubit entangled state. The Hadamard gate places the first qubit into a balanced superposition. The controlled-NOT gate then links the second qubit to the first. After measurement, the results should primarily appear as matching bit strings, such as 00 and 11, although simulator and hardware behavior can differ.
Checklist by scenario
Scenario 1: Set up a clean beginner environment
- Install a supported Python version in a virtual environment.
- Upgrade your package installer before adding quantum packages.
- Install Qiskit and a local simulator package separately if your workflow requires one.
- Confirm that imports work before writing a larger program.
python -m venv .venv
# macOS or Linux
source .venv/bin/activate
# Windows PowerShell
.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install qiskit qiskit-aer
Package names and provider interfaces can change. If an installation command fails, check the current Qiskit documentation and the package documentation rather than mixing examples from different releases.
Scenario 2: Build and run your first circuit locally
Save the following as first_circuit.py. It uses a local Aer simulator, so it does not require an account or remote connection.
from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator
# Create two qubits and two classical bits.
circuit = QuantumCircuit(2, 2)
# Put qubit 0 into superposition and entangle it with qubit 1.
circuit.h(0)
circuit.cx(0, 1)
# Measure both qubits into the classical register.
circuit.measure(0, 0)
circuit.measure(1, 1)
# Select a local simulator and adapt the circuit to it.
backend = AerSimulator()
compiled_circuit = transpile(circuit, backend)
# Repeat the experiment so the distribution is visible.
job = backend.run(compiled_circuit, shots=1024)
result = job.result()
counts = result.get_counts()
print(circuit.draw())
print(counts)
Run it with python first_circuit.py. The output is a dictionary whose keys are measured bit strings and whose values are the number of times each result occurred. The exact counts vary because measurement is sampled. The important first checks are that the program runs, the circuit drawing contains the expected gates, and the results have the pattern you intended.
Scenario 3: Prepare for IBM Quantum execution
Remote execution requires an account, an authentication token, and a currently supported provider interface. The setup process and naming of channels or backends may change, so begin with the current IBM Quantum documentation. Do not place an access token directly in source code or commit it to a repository.
- Create or use an IBM Quantum account according to the provider’s current onboarding instructions.
- Install the provider package recommended for the Qiskit release you are using.
- Store credentials using the provider’s supported account or environment-variable mechanism.
- List available backends and select one based on qubit count, supported instructions, queue conditions, and experiment goals.
- Transpile the circuit for that backend before submitting it.
- Record the backend, shot count, software versions, and circuit definition with your results.
For repeatable work, separate circuit construction from backend selection. That makes it easier to compare a simulator with a remote device without rewriting the experiment.
What to double-check
- Qubit and bit order: Qiskit displays and reports bit strings using conventions that can surprise new users. Confirm which classical bit receives each measurement.
- Measurement placement: A circuit may simulate without measurements but cannot produce ordinary shot-based counts until measurements are included.
- Transpilation: A backend may rewrite gates to match its instruction set. Inspect the transpiled circuit when depth, connectivity, or gate count matters.
- Simulator versus hardware: A noiseless simulator is useful for validating logic, but real devices can introduce readout and gate errors.
- Shot count: More shots usually provide a clearer estimate of a probability distribution, but they do not correct a flawed circuit.
- Reproducibility: Save the source code, package versions, backend name, shots, transpiled circuit, and result metadata. The quantum experiment reproducibility checklist provides a broader record-keeping workflow.
Common mistakes
Installing only the core package: Qiskit and a simulator or remote provider may be distributed as separate packages. Install only the components your chosen workflow needs, then verify imports.
Expecting one result every time: Quantum measurement is probabilistic. A balanced circuit can produce different individual results while maintaining a stable distribution across many shots.
Confusing a circuit with its execution: Creating a QuantumCircuit defines instructions; it does not run them. A backend, transpilation step, job submission, and result retrieval complete the workflow.
Copying outdated provider code: Tutorials written for an earlier Qiskit release may use removed or renamed APIs. Check the version and migration notes before debugging line by line.
Sending large experiments to hardware too early: Validate a small circuit locally first. Then test a reduced version remotely before increasing depth, shots, or the number of circuits.
When to revisit
Return to this checklist whenever Qiskit, Aer, or an IBM Quantum provider changes its installation or execution APIs. Recheck the setup before starting a new project, moving from a simulator to hardware, upgrading a project environment, or sharing code with students or collaborators.
Before each run, use this short action list:
- Activate the intended virtual environment.
- Print or record relevant package versions.
- Draw the circuit and verify qubit, gate, and measurement order.
- Run a small local test before using a remote backend.
- Transpile for the selected backend and inspect the result.
- Save counts and metadata with a clear experiment name.
Once this workflow is familiar, extend it with parameterized circuits, noise models, or a quantum machine learning library. Keep the first circuit as a known-good test: it is a practical way to detect environment and provider changes before they affect a larger experiment.