Skip to content

Latest commit

 

History

History
149 lines (105 loc) · 4.19 KB

INSTALL.md

File metadata and controls

149 lines (105 loc) · 4.19 KB

Qiskit Tutorials

Installation and setup

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.

Install Qiskit

At least Python 3.6 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:

  1. Install conda

  2. Create conda environment for Qiskit and install packages (with the accompanying environment.yml file)

cd qiskit-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

3. Configure your IBM Q Provider

  • 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 the IBMQ.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.

4. Explore the Tutorials

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

5. [Optional] Visualizing Circuits with LaTeX

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

On MacOS:

  • Install MiKTeX.
  • Install Poppler:
    • Run: brew install poppler

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.