qiskit-documentation/docs/guides/install-qiskit-source.mdx

152 lines
4.9 KiB
Plaintext

---
title: Install the Qiskit SDK from source
description: Learn how to install the development version of Qiskit.
---
# Install the Qiskit SDK and Qiskit Runtime from source
Installing the Qiskit SDK from source allows you to access the current development version, instead of using the version in the Python Package Index (PyPI) repository. This lets you inspect and extend the latest version of the Qiskit code more efficiently.
## Create and activate a new virtual environment
1. Create a minimal environment with only Python installed in it.
<OperatingSystemTabs>
<TabItem value="mac" label="macOS">
```shell
python3 -m venv /path/to/virtual/environment
```
</TabItem>
<TabItem value="linux" label="Linux">
```shell
python3 -m venv /path/to/virtual/environment
```
</TabItem>
<TabItem value="win" label="Windows">
```text
python3 -m venv c:\path\to\virtual\environment
```
</TabItem>
</OperatingSystemTabs>
1. Activate your new environment.
<OperatingSystemTabs>
<TabItem value="mac" label="macOS">
```shell
source /path/to/virtual/environment/bin/activate
```
</TabItem>
<TabItem value="linux" label="Linux">
```shell
source /path/to/virtual/environment/bin/activate
```
</TabItem>
<TabItem value="win" label="Windows">
```text
c:\path\to\virtual\environment\Scripts\Activate.ps1
```
</TabItem>
</OperatingSystemTabs>
## 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](https://rustup.rs/) or [another install method.](https://forge.rust-lang.org/infra/other-installation-methods.html)
## Install Qiskit
Follow these steps to install Qiskit:
1. Clone the Qiskit repository.
```bash
git clone https://github.com/Qiskit/qiskit.git
```
2. Change to the `qiskit` directory.
```bash
cd qiskit
```
3. (Optional) If you want to run tests or linting checks, install the developer requirements.
```bash
pip install -r requirements-dev.txt
```
4. Install `qiskit`.
* **Standard install**:
```bash
pip install .
```
* **Editable mode**: In this mode, you don't need to reinstall Qiskit when there are code changes to the project.
```bash
pip install -e .
```
In editable mode, the compiled extensions are built in _debug mode_ without optimizations. This affects the runtime performance of the compiled code. To build the compiled extensions with optimizations enabled, run the following command to rebuild the binary in _release mode_:
```bash
python setup.py build_rust --release --inplace
```
<Admonition type="note">
If you are working on Rust code in Qiskit, you need to rebuild the extension code every time you make a local change. In editable mode, the Rust extension is only built when the install command is run, so local changes you make to the Rust code are not reflected in the installed package unless you rebuild the extension by rerunning `build_rust` (with or without `--release`, depending on whether you want to build in release or debug mode).
</Admonition>
## Install Qiskit Runtime
Follow these steps if you want to install Qiskit Runtime:
1. Clone the Qiskit Runtime repository.
```bash
git clone https://github.com/Qiskit/qiskit-ibm-runtime.git
```
2. Change to the `qiskit_ibm_runtime` directory.
```bash
cd qiskit_ibm_runtime
```
3. (Optional) If you want to run tests or linting checks, install the developer requirements. We recommend using a [virtual environment](https://docs.python.org/3/library/venv.html) to avoid polluting your global Python installation.
```bash
pip install -r requirements-dev.txt
```
4. Install `qiskit-runtime`. We recommend using a [virtual environment](https://docs.python.org/3/library/venv.html) to avoid polluting your global Python installation.
* **Standard install**:
```bash
pip install .
```
* **Editable mode**: In this mode, you don't need to reinstall Qiskit when there are code changes to the project.
```bash
pip install -e .
```
In editable mode, the compiled extensions are built in _debug mode_ without optimizations.
## Next steps
<Admonition type="tip" title="Recommendations">
- Read the [contributing guidelines](https://github.com/Qiskit/qiskit/blob/main/CONTRIBUTING.md) to contribute to the open-source Qiskit SDK.
- Learn how to [build circuits](./map-problem-to-circuits).
- [Run the Hello world program](hello-world).
- Try a tutorial, such as [Grover's algorithm](https://learning.quantum.ibm.com/tutorial/grovers-algorithm).
</Admonition>