Get the tutorials
For the full experience, you can start by downloading the latest release of the tutorials from here. Unzip the archive in the directory of your choice (this is the recommended way).
To properly view and run the tutorials, you will need to install Jupyter Notebook.
At least Python 3.5 or later is required
to install and use Qiskit. If you have multiple Python versions installed (and
particularly if the command python --version
returns an incompatible
version), you will need to ensure that your versions are managed
correctly.
This can be done using the environment.yml
file, as detailed below.
When there are no issues with dependencies, Qiskit can be installed using
pip install qiskit
Or, a pre-installed Qiskit can be updated using
pip install -U qiskit
However, in case of issues with dependencies, we recommend the following installation procedure:
-
Install conda
-
Create conda environment for Qiskit and install packages (with the accompanying
environment.yml
file)
cd qiskit-iqx-tutorials
conda env create -f environment.yml
If you have already created environment
, you can upgrade it by running
conda env update -f environment.yml
- Create an IBM Q account if you haven't already done so
- Get an API token from the IBM Q website under “My Account" > "Qiskit in local environment"
- We are now going to add the necessary credentials to Qiskit. Take your
token, here called
MY_API_TOKEN
, and pass it to theIBMQ.save_account()
function:
from qiskit import IBMQ
IBMQ.save_account('MY_API_TOKEN')
- Your credentials will be stored on disk. Once they are stored, at any point in the future you can load and use them via:
from qiskit import IBMQ
provider = IBMQ.load_account()
- For those who do not want to save their credentials to disk, please use
from qiskit import IBMQ
provider = IBMQ.enable_account('MY_API_TOKEN')
and the token will only be active for the session.
Activate the environment
For MacOS and Linux, run:
source activate Qiskitenv
For Windows, run:
activate Qiskitenv
Note for conda users
Verify that you have installed the right Jupyter Kernel, because in the last
conda version it's not installed by default.
python -m ipykernel install --user --name Qiskitenv --display-name "Python (Qiskitenv)"
Start Jupyter with the index notebook
jupyter notebook index.ipynb
You can visualize your quantum circuits directly from Qiskit. Qiskit circuit
drawers support text, LaTeX and matplotlib. The text and matplotlib version is
entirely native to Python, and thus easy to use. The LaTeX version produces
publication-quality circuit images, but relies on some pre-requisite software.
These include the pdflatex
compiler for rendering LaTeX documents, and the
Poppler library for converting PDF to image. To get these:
On Linux:
- Install MiKTeX
- Install Poppler:
- Run:
apt-get install -y poppler-utils
- Run:
On MacOS:
- Install MiKTeX.
- Install Poppler:
- Run:
brew install poppler
- Run:
On Windows:
- Install MiKTeX.
- Install Poppler:
- Download the latest binary.
- Extract the downloaded
.7z
file into user directory:c:\Users\<user_name>\
. Note: You will need to have the 7zip software for this. - Add to PATH:
- Right click on "This PC" -> Properties -> Advanced System Settings -> Environment Variables
- Add
C:\Users\<user_name>\poppler-0.51\bin
to the user's path.