Set up a Q# and Python environment
Learn how to configure a Python development environment to develop Python host programs that call Q# operations.
Install the qsharp Python package
The qsharp Python package, which includes the IQ# kernel, contains the necessary functionality for compiling and simulating Q# operations from a regular Python program.
Install Miniconda or Anaconda. Consult their installation guide if you are unsure about any steps. Note: 64-bit installation required.
Initialize conda for your preferred shell with the
conda initinitialization command. The steps below are tailored to your operating system:(Windows) Open an Anaconda Prompt by searching for it in the start menu. Then run the initialization command for your shell, for example,
conda init powershell cmd.exewill set up both the Windows PowerShell and Command Prompt for you. You can then close this prompt.Important
To work with PowerShell, conda will configure a startup script to run whenever you launch a PowerShell instance. By default, the script's execution will be blocked on Windows, and requires modifying the PowerShell execution policy with the following command (executed from within PowerShell):
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned(Linux) If haven't done so during installation, you can still initialize conda now. Open a terminal and navigate to the
bindirectory inside your selected install location (for example,/home/ubuntu/miniconda3/bin). Then run the appropriate command for your shell, for example,./conda init bash. Close your terminal for the changes to take effect.From a new terminal, create and activate a new conda environment named
qsharp-envwith the required packages (including Jupyter Notebook and IQ#) by running the following commands:conda create -n qsharp-env -c microsoft qsharp notebook conda activate qsharp-envFinally, run
python -c "import qsharp"to verify your installation and populate your local package cache with all required QDK components.
That's it! You now have both the qsharp Python package and the IQ# kernel for Jupyter, allowing you to compile and run Q# operations from Python and Q# Jupyter Notebooks.
Next steps
Now that you have set up your Python environment, you can write and run quantum programs against local quantum simulators or remote quantum hardware.
الملاحظات
إرسال الملاحظات وعرضها المتعلقة بـ