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.
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
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