Browse the glossary using this index

Special | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | ALL
Picture of Yee Wei Law

Qiskit: setup

by Yee Wei Law - Friday, 9 August 2024, 1:10 PM
 

This entry continues from installation of QuTiP.

  1. Make sure you are in a Conda command prompt and the environment “cyber” is activated. As per official documentation, install qiskit and galois:

    pip install qiskit[visualization] qiskit-aer qiskit-ibm-runtime galois

    galois is not necessary for qiskit but necessary for our courses.

    Qiskit usually uses NumPy of a lower version than what QuTiP uses, so expect existing NumPy to be downgraded.

  2. Subsequently, as per official documentation, install the qiskit_textbook package:

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

    Qiskit Textbook is a community project offering learning resources that will be useful to us.

  3. Test Qiskit in a Python shell:

    Fig: 1: Testing Qiskit in a Python shell.

    The two commands in the screenshot above ☝ should not trigger any error.

  4. Next, test Qiskit in JupyterLab. To launch JupyterLab, as per official documentation, open a Conda prompt (not Python shell) and type:

    jupyter lab

    Expect a web browser window to be launched, where you can create a new “Python 3 (ipykernel)” notebook:

    Fig: 2: JupyterLab landing page.

    Note ipykernel is an interactive Python kernel for Jupyter.

    Copying the first piece of code from the “Introduction to Qiskit” tutorial and pasting it into the newly created “Python 3 (ipykernel)” notebook should produce the circuit diagram at the bottom of this screenshot:

    Fig: 3: Sample Qiskit code running in Jupyter notebook.

Qiskit comes with a super-quick introduction to Python and Jupyter notebooks.

Visual Studio Code is a popular alternative to a web browser for hosting Jupyter notebooks, but to minimise the number of software components that can go wrong, we shall stick with a web browser (for which Mozilla Firefox is recommended).

Tags: