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
-
Navigate to your project directory and create a minimal environment with only Python installed in it.
python3 -m venv .venvpython3 -m venv .venvpython -m venv .venv -
Activate your new environment.
source .venv/bin/activatesource .venv/bin/activate.venv\Scripts\Activate.ps1
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
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:
- Clone the Qiskit repository.
git clone https://github.com/Qiskit/qiskit.git- Change to the
qiskitdirectory.
cd qiskit- (Optional) If you want to run tests or linting checks, install the developer requirements.
pip install --group dev- 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.
NoteIf 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:releaseordebug).Choose the build profile. If unset, then
releasein standard-mode builds anddebugin editable-mode builds.releaseturns on optimizations, and is necessary for good performance.debugdoes minimal optimization, and leaves debugging symbols in the compiled extensions. -
QISKIT_BUILD_WITH_MIMALLOC(values:0or1, default0).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:0or1, default0).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
- Read the contributing guidelines to contribute to the open-source Qiskit SDK.
- Run your first quantum circuit.
- Try a tutorial, such as Grover's algorithm.