The new Qiskit Textbook beta is now available. Try it out now
Setting Up Your Environment

This is a comprehensive guide for setting up your environment on your personal computer for working with Qiskit Textbook. This will help you reproduce the results as you see them on the textbook website. The Qiskit Textbook is written in Jupyter notebooks. Notebooks and the website are the only media in which the Textbook is fully supported.

Installing the qiskit_textbook Package

The Qiskit Textbook provides some tools and widgets specific to the Textbook. This is not part of Qiskit and is available through the qiskit_textbook package. The quickest way to install this with Pip and Git is through the command:

pip install git+https://github.com/qiskit-community/qiskit-textbook.git#subdirectory=qiskit-textbook-src

Alternatively, you can download the folder qiskit-textbook-src from the Github and run:

pip install ./qiskit-textbook-src

from the directory that contains this folder.

Steps to reproduce exact prerendered output as given in qiskit textbook (Optional)

1. Setting up default drawer to Matplotlib

The default backend for QuantumCircuit.draw() or qiskit.visualization.circuit_drawer() is the text backend. However, depending on your local environment you may want to change these defaults to something better suited for your use case. This is done with the user config file. By default the user config file should be located in ~/.qiskit/ and is the settings.conf file.

Qiskit Textbook uses default circuit drawer as Matplotlib. To reproduce visualizations as given in qiskit textbook create a settings.conf file (usually found in ~/.qiskit/) with contents:

[default]
circuit_drawer = mpl

2. Setting up default image type to svg

Optionally, you can add the following line of code to the ipython_kernel_config.py file (usually found in ~/.ipython/profile_default/) to set the default image format from PNG to the more scaleable SVG format:

c.InlineBackend.figure_format = 'svg'

3. Syncing with the Qiskit versions used in the Textbook

You will find a code snippet at the end of the most tutorials which will contain the information on which versions of qiskit packages are used in the tutorial. If you find inconsistency in syntax and/or outputs, try to use the same version.

To check the version installed in your computer, run the following in Python shell or Jupyter Notebook:

import qiskit.tools.jupyter
%qiskit_version_table