Setting Up Qiskit On Your Computer

Madeline Farina
QubitCo
Published in
4 min readSep 3, 2020

Qiskit is an open-source framework developed by IBM for coding with quantum computing. Although this sounds complex, it is actually quite easy (and fun!) to set up and start using on your own laptop or desktop, with no software purchases required. The following is a comprehensive tutorial for beginners which will walk you through installing Qiskit and using it in a Jupyter Notebook. It involves working in your terminal (or Command Prompt, for Windows users), but all the commands are relatively straightforward and pose no danger to your machine.

The official Qiskit YouTube channel has a tutorial for this as part of their Coding with Qiskit series, which I highly recommend. If you would prefer a video walkthrough of this process, you can find it here. Otherwise, continue reading below.

Step 1. Install Anaconda distribution

First, you must install the current version of Anaconda for your machine. Anaconda is a distribution of Python, a common programming language and the basis of Qiskit. Go to to official Anaconda website here and scroll down until you see this:

Download the appropriate distribution for your machine and walk through the installation process, using the default settings. You will need to download an executable, so choose the 64-bit Graphical Installer. When I first downloaded it, there was the option between a distribution for Python 2.7 and 3.7. Although that doesn’t seem to be an option any more, make sure you choose Python 3.7 if possible.

Step 2. Install Qiskit with pip

Open up your Terminal (or Command Prompt, for Windows users) and type the following command:

pip install qiskit

which will install Qiskit on your machine. If you encounter an error here, you may need to run this command as root user (so try sudo pip install qiskit).

Step 3. Create a new Jupyter Notebook

To start a Jupyter Notebook interface where you can run Qiskit code, run the following command in your Terminal:

jupyter notebook

This will automatically open a new browser window with a Jupyter Notebook.

Create a new notebook for python 3 by going to the “New” button on the right and selecting “Python 3” under “notebook” from the drop-down menu.

NOTE: There is another way to run a Jupyter notebook if you wish to avoid running a command in the Terminal, and if you have access to Google Drive. If you have a .ipynb file saved on your computer and you upload it to your Google Drive, you can right-click the file and open it with with Google Colaboratory. You may need to install Google Colaboratory as an app, but once it’s installed, you can run Jupyter Notebooks within Google Drive with no further steps required.

Step 4. Import Qiskit in the Jupyter Notebook

To import Qiskit in the notebook, run

then press shift + enter to complete the command. If Qiskit has been properly installed, the line should execute with no error messages. Check your Qiskit version with qiskit.__qiskit_version__ like so:

Step 5. Make an IBM account to get an API token

To access the quantum devices at IBM, you need to get an API token. To do so, make IBMid here, which should take you to the website above. By getting an access token, you can run Qiskit code not only locally on your own computer, but also on real quantum computers at IBM (neat, right?).

Once you make an account, go to top right corner and click on the person icon, then on My Account in the drop-down menu. Select the blue “copy token” button to copy your API token to your clipboard.

Step 6. Import the API token

In the Jupyter Notebook, type:

and hit shift + enter then type:

(replace the red text with your actual API token)

And finally, type the following to finish the process:

And there you have it! You are ready to start coding with Qiskit. If you encountered any errors in this process, feel free to leave a comment or use any of the resources in this page to solve the issue. Often times the most helpful thing to do is look up “Qiskit <your operating system> <error>” with your search engine of choice.

Qiskit documentation can be found here for further questions.

--

--

Madeline Farina
QubitCo

Quantum Physics, InfoSec, and general scientific nonsense