Skill Tracer
Skills › Scientific Agent Skills › qiskit › setup.md

setup.md

257 lines · skills/qiskit/references/setup.md at 5f2bc03

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1# Setup, Versions, and Authentication
2

Setup, Versions, and Authentication

Raw lines 1 to 2
3## Reviewed Version Baseline
4
5Checked against PyPI and official release notes on **2026-10-01**:
6
7| Distribution | Reviewed version | Purpose | Python requirement |
8|---|---:|---|---|
9| `qiskit` | 2.5.2 | Core circuits, operators, transpiler, local statevector primitives | Python 3.10+ |
10| `qiskit-ibm-runtime` | 0.50.0 | IBM Quantum Platform service and Runtime primitives | Python 3.10+ |
11| `qiskit-aer` | 0.17.2 | High-performance and noisy simulation | See its PyPI metadata |
12| `qiskit-algorithms` | 0.4.0 | VQE, QAOA, Grover, phase estimation, optimizers | Python 3.9+ |
13| `qiskit-nature` | 0.8.0 | Quantum chemistry and second-quantized problems | Python 3.10+ |
14| `qiskit-nature-pyscf` | 0.4.0 | PySCF integration for Qiskit Nature | Python 3.8+ |
15| `qiskit-machine-learning` | 0.9.1 | Quantum kernels, QNNs, Torch integration | Python 3.10+ |
16| `qiskit-optimization` | 0.7.0 | Quadratic programs and quantum optimizers | Python 3.9+ |
18Local core, Runtime/Aer, Algorithms, Optimization, and visualization checks used these releases. Nature, Machine Learning, and addons were checked against official documentation and release metadata; their workflows below are illustrative and were not executed in this refresh.

Reviewed Version Baseline

Checked against PyPI and official release notes on 2026-10-01:

DistributionReviewed versionPurposePython requirement
qiskit2.5.2Core circuits, operators, transpiler, local statevector primitivesPython 3.10+
qiskit-ibm-runtime0.50.0IBM Quantum Platform service and Runtime primitivesPython 3.10+
qiskit-aer0.17.2High-performance and noisy simulationSee its PyPI metadata
qiskit-algorithms0.4.0VQE, QAOA, Grover, phase estimation, optimizersPython 3.9+
qiskit-nature0.8.0Quantum chemistry and second-quantized problemsPython 3.10+
qiskit-nature-pyscf0.4.0PySCF integration for Qiskit NaturePython 3.8+
qiskit-machine-learning0.9.1Quantum kernels, QNNs, Torch integrationPython 3.10+
qiskit-optimization0.7.0Quadratic programs and quantum optimizersPython 3.9+

Local core, Runtime/Aer, Algorithms, Optimization, and visualization checks used these releases. Nature, Machine Learning, and addons were checked against official documentation and release metadata; their workflows below are illustrative and were not executed in this refresh.

Raw lines 3 to 19
20## Create an Environment
22The repository recommends Python 3.13. Qiskit 2.5 supports CPython 3.10 and newer on supported 64-bit platforms.
24```bash
25uv venv --python 3.13
26source .venv/bin/activate
27```
29On Windows PowerShell:
31```powershell
32uv venv --python 3.13
33.venv\Scripts\Activate.ps1
34```
36Install the smallest useful set:
38```bash
39# Core SDK
40uv pip install "qiskit==2.5.2"
42# Core plus Matplotlib/LaTeX visualization dependencies
43uv pip install "qiskit[visualization]==2.5.2"
45# IBM QPUs and Runtime primitives
46uv pip install "qiskit-ibm-runtime==0.50.0"
48# High-performance and noisy simulation
49uv pip install "qiskit-aer==0.17.2"
50```
52For a project, declare the same exact pins with `uv add`:
54```bash
55uv add "qiskit[visualization]==2.5.2"
56uv add "qiskit-ibm-runtime==0.50.0"
57uv add "qiskit-aer==0.17.2"
58```
60Do not install `qiskit-terra`. Since Qiskit 1.0, the `qiskit` distribution owns the complete `qiskit` package namespace. Aer and application packages remain separate distributions.

Create an Environment

The repository recommends Python 3.13. Qiskit 2.5 supports CPython 3.10 and newer on supported 64-bit platforms.

uv venv --python 3.13
source .venv/bin/activate

On Windows PowerShell:

uv venv --python 3.13
.venv\Scripts\Activate.ps1

Install the smallest useful set:

# Core SDK
uv pip install "qiskit==2.5.2"

# Core plus Matplotlib/LaTeX visualization dependencies
uv pip install "qiskit[visualization]==2.5.2"

# IBM QPUs and Runtime primitives
uv pip install "qiskit-ibm-runtime==0.50.0"

# High-performance and noisy simulation
uv pip install "qiskit-aer==0.17.2"

For a project, declare the same exact pins with uv add:

uv add "qiskit[visualization]==2.5.2"
uv add "qiskit-ibm-runtime==0.50.0"
uv add "qiskit-aer==0.17.2"

Do not install qiskit-terra. Since Qiskit 1.0, the qiskit distribution owns the complete qiskit package namespace. Aer and application packages remain separate distributions.

Raw lines 20 to 61
Runs code bin/activate :26
62## Optional Application Packages
64Install these only for the corresponding workflow:
66```bash
67uv pip install "qiskit-algorithms==0.4.0"
68uv pip install "qiskit-nature[pyscf]==0.8.0"
69# Optional reverse integration: PySCF calls a Qiskit Nature solver
70uv pip install "qiskit-nature-pyscf==0.4.0"
71uv pip install "qiskit-machine-learning==0.9.1"
72uv pip install "qiskit-optimization==0.7.0"
73```
75Resolve all selected packages together in a fresh environment. Do not force-install incompatible distributions with dependency checks disabled.

Optional Application Packages

Install these only for the corresponding workflow:

uv pip install "qiskit-algorithms==0.4.0"
uv pip install "qiskit-nature[pyscf]==0.8.0"
# Optional reverse integration: PySCF calls a Qiskit Nature solver
uv pip install "qiskit-nature-pyscf==0.4.0"
uv pip install "qiskit-machine-learning==0.9.1"
uv pip install "qiskit-optimization==0.7.0"

Resolve all selected packages together in a fresh environment. Do not force-install incompatible distributions with dependency checks disabled.

Raw lines 62 to 76
77## Verify the Environment
79Use the bundled checker:
81```bash
82python scripts/check_environment.py
83python scripts/check_environment.py --require-runtime --require-aer
84python scripts/check_environment.py --json
85```
87Or inspect versions directly:
89```python
90from importlib.metadata import version
92for distribution in ("qiskit", "qiskit-ibm-runtime", "qiskit-aer"):
93 try:
94 print(distribution, version(distribution))
95 except Exception:
96 print(distribution, "not installed")
97```
99Run the local smoke test before configuring cloud access:
101```bash
102python scripts/run_local_primitives.py --shots 256 --seed 7
103```

Verify the Environment

Use the bundled checker:

python scripts/check_environment.py
python scripts/check_environment.py --require-runtime --require-aer
python scripts/check_environment.py --json

Or inspect versions directly:

from importlib.metadata import version

for distribution in ("qiskit", "qiskit-ibm-runtime", "qiskit-aer"):
    try:
        print(distribution, version(distribution))
    except Exception:
        print(distribution, "not installed")

Run the local smoke test before configuring cloud access:

python scripts/run_local_primitives.py --shots 256 --seed 7
Raw lines 77 to 104
Runs code python scripts/check_environment.py :82
Runs code python scripts/run_local_primitives.py :102
105## IBM Quantum Platform Setup
107IBM QPU access requires:
1091. An IBM Cloud account.
1102. An IBM Quantum Platform instance or access to an organization's instance.
1113. An IBM Cloud API key.
1124. `qiskit-ibm-runtime`.
114Use the current channel name, `ibm_quantum_platform`. The old `ibm_quantum` channel is no longer supported. `ibm_cloud` currently reaches the upgraded platform but is a legacy alias; use `ibm_quantum_platform` in new code.
116Create and manage API keys through the [IBM Cloud API keys page](https://cloud.ibm.com/iam/apikeys). Find instance names and Cloud Resource Names (CRNs) on the [IBM Quantum Platform Instances page](https://quantum.cloud.ibm.com/instances).

IBM Quantum Platform Setup

IBM QPU access requires:

  1. An IBM Cloud account.
  2. An IBM Quantum Platform instance or access to an organization's instance.
  3. An IBM Cloud API key.
  4. qiskit-ibm-runtime.

Use the current channel name, ibm_quantum_platform. The old ibm_quantum channel is no longer supported. ibm_cloud currently reaches the upgraded platform but is a legacy alias; use ibm_quantum_platform in new code.

Create and manage API keys through the IBM Cloud API keys page. Find instance names and Cloud Resource Names (CRNs) on the IBM Quantum Platform Instances page.

Raw lines 105 to 117
118### Trusted Workstation: Save an Account
120Put only the named values into the process environment. Never hardcode, print, log, or commit an API key.
122```bash
123export IBM_QUANTUM_API_KEY="set-this-outside-source-control"
124# Optional: restrict access to one instance
125export IBM_QUANTUM_INSTANCE="instance-name-or-crn"
126```
128Then save the account from a trusted machine:
130```python
131import os
132from qiskit_ibm_runtime import QiskitRuntimeService
134api_key = os.environ["IBM_QUANTUM_API_KEY"]
135instance = os.environ.get("IBM_QUANTUM_INSTANCE")
137QiskitRuntimeService.save_account(
138 channel="ibm_quantum_platform",
139 token=api_key,
140 instance=instance,
141 name="default-platform",
142 set_as_default=True,
143 overwrite=True,
145```
147The SDK stores saved credentials in `$HOME/.qiskit/qiskit-ibm.json`. Do not manually edit, print, upload, or commit this file. Restrict local file access to the current user.
149Load saved credentials without putting a token in source:
151```python
152from qiskit_ibm_runtime import QiskitRuntimeService
154service = QiskitRuntimeService(name="default-platform")
155```
157If only one default account exists, `QiskitRuntimeService()` is sufficient. Pin the intended instance CRN for reproducible hardware work: selecting across instances can change the active billing allocation. `instance="auto"` explicitly opts into automatic selection; `plans_preference=["open"]` can restrict automatic discovery to Open Plan. The public alias `IBMQuantumComputeService` is also available since Runtime 0.49.
159`channel="local"` creates a local service without cloud credentials. Never infer cloud access from a successful local service test.

Trusted Workstation: Save an Account

Put only the named values into the process environment. Never hardcode, print, log, or commit an API key.

export IBM_QUANTUM_API_KEY="set-this-outside-source-control"
# Optional: restrict access to one instance
export IBM_QUANTUM_INSTANCE="instance-name-or-crn"

Then save the account from a trusted machine:

import os
from qiskit_ibm_runtime import QiskitRuntimeService

api_key = os.environ["IBM_QUANTUM_API_KEY"]
instance = os.environ.get("IBM_QUANTUM_INSTANCE")

QiskitRuntimeService.save_account(
    channel="ibm_quantum_platform",
    token=api_key,
    instance=instance,
    name="default-platform",
    set_as_default=True,
    overwrite=True,
)

The SDK stores saved credentials in $HOME/.qiskit/qiskit-ibm.json. Do not manually edit, print, upload, or commit this file. Restrict local file access to the current user.

Load saved credentials without putting a token in source:

from qiskit_ibm_runtime import QiskitRuntimeService

service = QiskitRuntimeService(name="default-platform")

If only one default account exists, QiskitRuntimeService() is sufficient. Pin the intended instance CRN for reproducible hardware work: selecting across instances can change the active billing allocation. instance="auto" explicitly opts into automatic selection; plans_preference=["open"] can restrict automatic discovery to Open Plan. The public alias IBMQuantumComputeService is also available since Runtime 0.49.

channel="local" creates a local service without cloud credentials. Never infer cloud access from a successful local service test.

Raw lines 118 to 160
161### CI or Ephemeral Machine: Do Not Persist
163Inject the two named secrets through the CI secret store and instantiate the service directly:
165```python
166import os
167from qiskit_ibm_runtime import QiskitRuntimeService
169service = QiskitRuntimeService(
170 channel="ibm_quantum_platform",
171 token=os.environ["IBM_QUANTUM_API_KEY"],
172 instance=os.environ["IBM_QUANTUM_INSTANCE"],
174```
176Do not call `save_account()` on a shared runner. Do not dump the environment, the service account object, or exception payloads that may contain request details.
178If an API key is exposed, revoke it immediately in IBM Cloud and replace it everywhere it was used.

CI or Ephemeral Machine: Do Not Persist

Inject the two named secrets through the CI secret store and instantiate the service directly:

import os
from qiskit_ibm_runtime import QiskitRuntimeService

service = QiskitRuntimeService(
    channel="ibm_quantum_platform",
    token=os.environ["IBM_QUANTUM_API_KEY"],
    instance=os.environ["IBM_QUANTUM_INSTANCE"],
)

Do not call save_account() on a shared runner. Do not dump the environment, the service account object, or exception payloads that may contain request details.

If an API key is exposed, revoke it immediately in IBM Cloud and replace it everywhere it was used.

Raw lines 161 to 179
180## Confirm Access Without Submitting a Job
182The bundled inspector uses saved credentials, performs read-only service queries, and never submits a workload:
184```bash
185python scripts/inspect_runtime.py --min-qubits 5
186python scripts/inspect_runtime.py --backend BACKEND_NAME --json
187```
189Equivalent minimal check:
191```python
192from qiskit_ibm_runtime import QiskitRuntimeService
194service = QiskitRuntimeService()
195backend = service.least_busy(
196 operational=True,
197 simulator=False,
198 min_num_qubits=5,
200print(backend.name, backend.num_qubits)
201```
203Do not hardcode a backend name copied from an old tutorial. Available systems and access rights change.

Confirm Access Without Submitting a Job

The bundled inspector uses saved credentials, performs read-only service queries, and never submits a workload:

python scripts/inspect_runtime.py --min-qubits 5
python scripts/inspect_runtime.py --backend BACKEND_NAME --json

Equivalent minimal check:

from qiskit_ibm_runtime import QiskitRuntimeService

service = QiskitRuntimeService()
backend = service.least_busy(
    operational=True,
    simulator=False,
    min_num_qubits=5,
)
print(backend.name, backend.num_qubits)

Do not hardcode a backend name copied from an old tutorial. Available systems and access rights change.

Raw lines 180 to 204
Runs code python scripts/inspect_runtime.py :185
205## Local-Only Development
207No account or network access is needed for:
209- `StatevectorSampler`
210- `StatevectorEstimator`
211- `Statevector`, `DensityMatrix`, and other `qiskit.quantum_info` tools
212- Qiskit Aer simulators
213- fake backends bundled with `qiskit-ibm-runtime`
215Use local primitives for algorithm logic, Aer for larger/noisy simulations, and fake backends for target-aware compilation tests.

Local-Only Development

No account or network access is needed for:

  • StatevectorSampler
  • StatevectorEstimator
  • Statevector, DensityMatrix, and other qiskit.quantum_info tools
  • Qiskit Aer simulators
  • fake backends bundled with qiskit-ibm-runtime

Use local primitives for algorithm logic, Aer for larger/noisy simulations, and fake backends for target-aware compilation tests.

Raw lines 205 to 216
217## Repair a Broken Pre-1.0 Environment
219Typical symptoms include:
221- An error saying Qiskit is installed in an invalid environment.
222- Both `qiskit-terra` and modern `qiskit` distributions are present.
223- Imports resolve to files left behind by an old namespace-package installation.
224- A notebook kernel uses a different Python interpreter from the activated environment.
226The reliable repair is a new environment:
228```bash
229deactivate 2>/dev/null || true
230uv venv --python 3.13 .venv-qiskit
231source .venv-qiskit/bin/activate
232uv pip install "qiskit[visualization]==2.5.2"
233```
235Avoid trying to repair a mixed pre-1.0 environment by repeatedly uninstalling individual packages; stale namespace files can remain.
237Confirm the active interpreter:
239```python
240import sys
241import qiskit
243print(sys.executable)
244print(qiskit.__version__)
245print(qiskit.__file__)
246```

Repair a Broken Pre-1.0 Environment

Typical symptoms include:

  • An error saying Qiskit is installed in an invalid environment.
  • Both qiskit-terra and modern qiskit distributions are present.
  • Imports resolve to files left behind by an old namespace-package installation.
  • A notebook kernel uses a different Python interpreter from the activated environment.

The reliable repair is a new environment:

deactivate 2>/dev/null || true
uv venv --python 3.13 .venv-qiskit
source .venv-qiskit/bin/activate
uv pip install "qiskit[visualization]==2.5.2"

Avoid trying to repair a mixed pre-1.0 environment by repeatedly uninstalling individual packages; stale namespace files can remain.

Confirm the active interpreter:

import sys
import qiskit

print(sys.executable)
print(qiskit.__version__)
print(qiskit.__file__)
Raw lines 217 to 247
Runs code bin/activate :231
248## Upgrade Policy
250For reproducible work:
2521. Pin all Qiskit distributions.
2532. Record Python, Qiskit, Runtime, Aer, and application-package versions with results.
2543. Read the SDK and Runtime release notes before updating.
2554. Re-run local primitive tests and transpilation snapshots.
2565. Revalidate Runtime option names and execution-mode restrictions.
2576. Upgrade in a new lockfile branch or environment, not in the middle of a paid QPU experiment.

Upgrade Policy

For reproducible work:

  1. Pin all Qiskit distributions.
  2. Record Python, Qiskit, Runtime, Aer, and application-package versions with results.
  3. Read the SDK and Runtime release notes before updating.
  4. Re-run local primitive tests and transpilation snapshots.
  5. Revalidate Runtime option names and execution-mode restrictions.
  6. Upgrade in a new lockfile branch or environment, not in the middle of a paid QPU experiment.
Raw lines 248 to 257