Skip to content
main
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Learn Quantum Computing with Python and Q#
Sample Code

Binder Prebuild Docker images

This repository provides sample code for Learn Quantum Computing with Python and Q# (Dr. Sarah Kaiser and Dr. Chris Granade, Manning Publications), available from Manning Publications, Amazon, and a variety of local resellers.

Below, we provide some instructions on getting started with each sample; please see Appendix A for more details.

Getting Started with Code Samples

The samples for Chapters 2 through 6 are written in Python, while the examples in Chapters 7 and later are written in Q# and are called from either Python or by IQ# Notebooks. All samples can be run in one of two ways, depending on your preferences:

Anaconda

The Anaconda distribution of Python 3 provides the conda package manager to help you install and work with software written in Python. You can use conda and the Quantum Development Kit together to run all of the samples in this book.

Prerequisites:

Once you have all of the prerequisites installed, you can create a conda environment using the configuration provided in this repository:

conda env create -f environment.yml

This will provide all of the Python software you'll need to get started into a new conda environment called qsharp-book. To use this new environment, run conda activate qsharp-book.

If you would optionally like to use IQ# from outside of your conda environment, you can use the .NET Core SDK:

dotnet tool install --global Microsoft.Quantum.IQSharp
dotnet iqsharp install

This step is not required to use the samples shown in the book.

Using devcontainers

If you prefer, you can also use Visual Studio Code and Docker together to automatically configure all of the software required for use with the code samples in this book.

Prerequisites:

For more details about how to install and use Docker, check out Docker in Action, 2nd Edition.

Once you have all of the prerequisites installed, open the folder containing these samples in Visual Studio Code. You should then be prompted to reopen the folder in a development container; if not, press Ctrl+Shift+P (Windows and Linux) or ⌘+Shift+P (macOS) to open the command pallet and type "Reopen in Container." This will automatically download and install all software required for use with these samples into a Docker container, and will run Visual Studio Code within that new container.

Known issues:

  • When using a devcontainer, the plotting examples in Chapter 8 and 9 can only be run through Jupyter Notebook, not by running host.py from the command line.
  • To run Jupyter Notebook, use jupyter notebook --ip 0.0.0.0 rather than just jupyter notebook, so as to allow your host operating system to access the Notebook server.