Set up the Quantum Development Kit extension

In this article, you learn how to install the Azure Quantum Development Kit (QDK) extension for Visual Studio Code and add support for Python, Jupyter Notebooks, and the Azure CLI.

Prerequisites

Install the QDK extension

To use the QDK in Visual Studio Code, install the QDK extension. You can also use the QDK in VS Code for the Web without installing the extension, but you won't have all the features of VS Code Desktop. For more information, see Different ways to run Q# programs.

Note

If you used previous versions of the QDK, run python -m pip uninstall qsharp qsharp-core qsharp-chemistry azure-quantum to avoid package version conflicts.

You can now write, debug, and run Q# programs against the built-in quantum simulator or, if you have an Azure account, connect and submit Q# programs to quantum hardware, all from VS Code.

To test your setup, see Submit Q# jobs to Azure Quantum.

Add support for Python and Jupyter Notebooks

With Python support in Visual Studio Code, you can embed or call Q# code from your Python programs or Jupyter Notebooks and run them on the built-in quantum simulator, or connect to your Azure workspace and submit your jobs to quantum hardware.

Prerequisites

  • A Python environment (3.9 or greater, 3.11 recommended) with Python and Pip installed.
  • VS Code with the QDK extension installed.

Install the required packages

To add Python and Jupyter Notebook support:

  1. Install the Python and Jupyter extensions for VS Code.

  2. Open the command line.

  3. Install the qsharp and azure-quantum packages:

    python -m pip install qsharp azure-quantum
    
  4. For Qiskit or Cirq support, install azure-quantum using the [qiskit] or [cirq] parameters:

    Important

    If you are updating from a previous Qiskit environment, see Update the azure-quantum package with Qiskit support.

    python -m pip install azure-quantum[qiskit]
    or
    python -m pip install azure-quantum[cirq]
    or
    python -m pip install azure-quantum[qiskit, cirq]
    
  5. Install optional Python packages you might need to display results and work in Jupyter Notebooks:

    python -m pip install ipykernel ipympl jupyterlab
    

To test your setup, see Submit Q# jobs with Python or Submit Q# jobs with Jupyter Notebooks.

Add support for the Azure CLI

The Azure CLI is an optional method for submitting quantum jobs using a terminal window in Visual Studio Code.

  1. Install the Azure CLI.

  2. Open a Windows command prompt.

  3. In the command prompt, run the following command to update to the latest Azure CLI quantum extension:

    az extension add \
        --upgrade \
        -n quantum
    

To test your setup, see Submit Q# jobs to Azure Quantum.