Edit

Share via


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 (VS Code) and add support for Python, Jupyter Notebook, and the Azure CLI.

Prerequisites

  • The latest version of VS Code.
  • If you want to submit jobs to Azure Quantum, then you need to have an Azure account with a quantum workspace. For more information, see Create an Azure Quantum workspace.

Install the QDK extension

To use the QDK in VS 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.

You can now write, debug, and run Q# programs against the built-in quantum simulator. Or, if you have an Azure account, you can 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 Notebook

With Python support in VS Code, you can embed or call Q# code from your Python programs or Jupyter notebooks, and run them on the built-in quantum simulator. You can also connect to your Azure Quantum workspace and submit your jobs to run on real quantum hardware.

Prerequisites

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

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 qdk Python library with the azure extra:

    python -m pip install qdk[azure]
    
  4. For Qiskit or Cirq support, install azure-quantum with the qiskit or cirq extras:

    Important

    If you're 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 to display results and work in Jupyter Notebook:

    python -m pip install qdk[jupyter] 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 VS 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.