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:
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.
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:
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.
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}
In this post, you learned about some of the following:
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.
In recent years, artificial intelligence (AI) has evolved to include more sophisticated and capable agents,…
Adaptive learning helps in tailoring learning experiences to fit the unique needs of each student.…
With the increasing demand for more powerful machine learning (ML) systems that can handle diverse…
Anxiety is a common mental health condition that affects millions of people around the world.…
In machine learning, confounder features or variables can significantly affect the accuracy and validity of…
Last updated: 26 Sept, 2024 Credit card fraud detection is a major concern for credit…