Quantum Computing

Quantum Computing – Two Ways to Install QISKit on Linux

This article represents different ways in which you can go about installing Quantum Information Science Kit (QISKit) on Linux and related distros such as Ubuntu. QISKit is software development kit (SDK) for writing quantum computing experiments, programs, and applications. In this post, you will learn about some of the following topics in relation to installing QISKit on Linux:

  • Install QISKit using PIP
  • Install QISKit from Github repository

Install QISKit using PIP

You can go about installing QISKit using PIP, a Package manager for installing python libraries. The catch here is the requirement of using Python 3.5. or later. Often, we have python 2.7. setup as a default python alternative for usage. PIP, thus, ends up using Python 2.7. version. Thus, it results in failure of QISKit installation using PIP. One would require setting Python 3.5. to be used. Read the detailed instructions and related concepts on installing QISKit using PIP on this page, How to Install QISKit using PIP.

Install QISKit from Github Repository

Prior to moving ahead with installing QISKit from Github, make sure you have Git installed.

Execute following command in your workspace and change to qiskit-sdk-py directory:

git clone https://github.com/QISKit/qiskit-sdk-py
cd qiskit-sdk-py

Next step is to install some of the following dependencies to work with QISKit as a standalone library:

  • IBMQuantumExperience>=1.8.19
  • requests>=2.18,<2.19
  • networkx>=1.11,<1.12
  • ply==3.10
  • numpy>=1.13,<1.14
  • scipy>=0.19,<0.20
  • matplotlib>=2.0,<2.1
  • sphinx>=1.6,<1.7
  • sympy>=1.0

All of these libraries are mentioned in qiskit-sdk-py/requirements.txt. All you need to install dependencies is execute the following command:

pip install -r requirements.txt

The following screenshot represents the successful installation of QISKit dependencies.

Figure 1. QISKit Dependencies

Next step is to set the PYTHONPATH environment variable to qiskit-sdk-py directory. This would enable you to execute your Quantum program from anywhere. Set the PYTHONPATH variable in .bashrc:

export PYTHONPATH=$PYTHONPATH:/home/support/workspace/qiskit-sdk-py

Open up a new terminal and create a folder in your workspace to start writing your quantum programs. Create your first quantum program such as that given below and save it as qc_helloworld.py.

from qiskit import QuantumProgram
qp = QuantumProgram()
qr = qp.create_quantum_register('qr',2)
cr = qp.create_classical_register('cr',2)
qc = qp.create_circuit('Bell',[qr],[cr])
qc.h(qr[0])
qc.cx(qr[0], qr[1])
qc.measure(qr[0], cr[0])
qc.measure(qr[1], cr[1])
result = qp.execute('Bell')
print(result.get_counts('Bell'))

Execute the program using the following command:

python qc_helloworld.py

It should print something similar to that given below:

{'11': 500, '00': 524}

Further Reading

Summary

In this post, you learned about some of the following:

  • Installing QISKit using PIP
  • Installing QISKit using Repository
  • Executing your first quantum program

Did you find this article useful? Do you have any questions about this article or installing/setting up QISKit? Leave a comment and ask your questions and I shall do my best to address your queries.

Latest posts by Ajitesh Kumar (see all)
Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking.

Share
Published by
Ajitesh Kumar

Recent Posts

What are AI Agents? How do they work?

Artificial Intelligence (AI) agents have started becoming an integral part of our lives. Imagine asking…

2 weeks ago

Agentic AI Design Patterns Examples

In the ever-evolving landscape of agentic AI workflows and applications, understanding and leveraging design patterns…

2 weeks ago

List of Agentic AI Resources, Papers, Courses

In this blog, I aim to provide a comprehensive list of valuable resources for learning…

2 weeks ago

Understanding FAR, FRR, and EER in Auth Systems

Have you ever wondered how systems determine whether to grant or deny access, and how…

2 weeks ago

Top 10 Gartner Technology Trends for 2025

What revolutionary technologies and industries will define the future of business in 2025? As we…

2 weeks ago

OpenAI GPT Models in 2024: What’s in it for Data Scientists

For data scientists and machine learning researchers, 2024 has been a landmark year in AI…

3 weeks ago