DeepPractise
DeepPractise

Installing Qiskit & Environment Setup

Track: Quantum Programming · Difficulty: Beginner · Est: 12 min

Installing Qiskit & Environment Setup

Overview

This page introduces the programming concept of a reproducible environment: the same code should run the same way on your machine tomorrow.

It answers: How do I set up Python and Qiskit locally without involving cloud accounts?

Conceptual Mapping

In theory, you write circuits. In practice, you need:

  • Python to write and run code
  • a virtual environment to isolate dependencies
  • Qiskit to represent circuits and run them on simulators

Think of it like a lab bench:

  • Python = your workbench
  • virtual environment = your dedicated workspace (keeps tools from interfering)
  • Qiskit = your circuit-building toolkit

Code Walkthrough

Below is a minimal setup flow using a virtual environment. Commands are short and standard.

  1. Create and activate a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
  1. Upgrade packaging tools (helps avoid install issues):
python -m pip install --upgrade pip
  1. Install Qiskit:
python -m pip install qiskit
  1. Verify installation:
python -c "import qiskit; print(qiskit.__version__)"

Optional (recommended): verify simulator support. If this import fails, install Aer.

python -c "from qiskit_aer import AerSimulator; print('Aer OK')"
python -m pip install qiskit-aer

Line by line (conceptually):

  • python3 -m venv .venv creates an isolated dependency set.
  • source .venv/bin/activate switches your shell to use that environment.
  • pip install qiskit downloads and installs Qiskit and dependencies into the environment.
  • The final command checks that Python can import Qiskit.
  • The final command checks that Python can import Qiskit.
  • The optional Aer check matches the simulator backend we’ll use in the next page.

What Happens Under the Hood

  • A virtual environment is just a folder containing its own Python interpreter and package directory.
  • When it’s activated, python and pip refer to the environment’s copies.
  • Installing Qiskit adds libraries that define circuit objects and simulator backends.

This matters because quantum SDKs evolve quickly. Isolation makes it easier to reproduce examples and avoid “it worked last week” problems.

Turtle Tip

Turtle Tip

Use one environment per learning project. If something breaks, you can delete .venv and recreate it—clean resets are a superpower.

Common Pitfalls

Common Pitfalls
  • Installing packages globally and then not knowing which Python is running your code.
  • Forgetting to activate the environment before installing or running.
  • Mixing multiple Python versions across terminals/editors.
  • Treating setup as the goal. Setup is just a stable starting line; the concepts matter more.

Quick Check

Quick Check
  1. Why use a virtual environment instead of installing Qiskit globally?
  2. What command verifies Qiskit is installed (conceptually: import succeeds)?
  3. What is one symptom of “wrong Python environment” problems?

What’s Next

Next you’ll build a one-qubit circuit, apply a gate, measure, and run it on a simulator. That will connect the circuit diagrams you know to executable code.