Skip to main contentIBM Quantum Documentation Preview
This is a preview build of IBM Quantum® documentation. Refer to quantum.cloud.ibm.com/docs for the official documentation.

Install the Qiskit SDK from source

When you install the Qiskit SDK from source, you can access the current development version, instead of using the version in the Python Package Index (PyPI) repository. You can therefore inspect and extend the latest version of the Qiskit code more efficiently.


Create and activate a new virtual environment

  1. Navigate to your project directory and create a minimal environment with only Python installed in it.

    python3 -m venv .venv
  2. Activate your new environment.

    source .venv/bin/activate

Install the Rust compiler

A Rust compiler must be installed on your system to compile Qiskit. To install the Rust compiler, use the cross-platform Rust installer rustup or another install method.


Install Qiskit

Note

Qiskit SDK maintains its own documentation on from-source builds for developers, which might be more up-to-date than these instructions.

Follow these steps to install Qiskit:

  1. Clone the Qiskit repository.
git clone https://github.com/Qiskit/qiskit.git
  1. Change to the qiskit directory.
cd qiskit
  1. (Optional) If you want to run tests or linting checks, install the developer requirements.
pip install --group dev
  1. Install qiskit. (Optional: read Configuring the build process for ways you can modify these commands.)
  • Standard install.

    Use a PEP-517-compatible builder to build the package. For example, if using pip:

    pip install .

    This builds the compiled extensions in "release" mode by default, with optimizations enabled.

  • Editable mode: In this mode, you don't need to reinstall Qiskit when there are code changes to the Python files in the project.

    Use a PEP-660-compatible builder to build the package. For example, if using pip:

    pip install -e .

    This builds the compiled extensions in "debug" mode by default, with optimizations disabled. This will be significantly slower than standard builds of Qiskit.

    Note

    If you are working on Rust code in Qiskit, you must manually rebuild the extension modules after changing the Rust files. You can do this by re-running the pip install -e . command.


Configuring the build process

Qiskit reads several environment variables during its build process, when using a PEP-517 or PEP-660 builder. You can set these to configure the build.

  • QISKIT_BUILD_PROFILE (values: release or debug).

    Choose the build profile. If unset, then release in standard-mode builds and debug in editable-mode builds. release turns on optimizations, and is necessary for good performance. debug does minimal optimization, and leaves debugging symbols in the compiled extensions.

  • QISKIT_BUILD_WITH_MIMALLOC (values: 0 or 1, default 0).

    If set to 1, then use mimalloc as the global allocator in the library, rather than the system default. Requires a C compiler.

  • QISKIT_NO_CACHE_GATES (values: 0 or 1, default 0).

    If set to 1, then suppress the runtime caching of Python instruction objects in the internal Rust code. This is typically more memory-efficient, but in Python-heavy workflows it is less performant.


Next steps

Recommendations