This article represents instructions and related concepts on how to install QISKit (Quantum Information Science Kit) using PIP. As per Wikipedia Page on PIP, PIP is a package management system used to install and manage software packages written in Python. This article assumes that you are working with Linux distributions (distros) OS such as Ubuntu etc.
The following topics are discussed in this article:
QISKit is a software development kit (SDK) comprising of Python-based software libraries that can be used to create quantum computing programs, compile them, and execute them on one of several backends (online Real quantum processors, and simulators).
Execute the following command to install Python PIP:
sudo apt install python-pip
Just to make sure that PIP installation went fine, execute following command to check the PIP version:
pip --version
Install QISkit using PIP install command such as following:
pip install qiskit
As I executed above command, I got the following error:
Could not find a version that satisfies the requirement qiskit (from versions: ) – No matching distribution found for qiskit
The possible reason can be that QISKit requires PIP to use Python of version 3.5 or later to install the QISKit packages. However, when I tried to install QISKit using pip install qiskit command, it tried to use python2.7 version. And, QISKit supports python 3.5.* and later versions. The same can be found on QISKit Github page or QISKit.org. The following are instructions related to how I went about fixing the problem of setting python to use python 3.5.* rather than python 2.7.*.
ls -l /usr/bin/python*
python --version
# Executing the following command would list python versions update-alternatives --list python
If the result is update-alternatives: error: no alternatives for python, execute following commands to set the installation alternatives of various python versions:
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
Execute the following command to check the python alternatives list:
update-alternatives --list python
The following would show up as part of the list:
Now, lets set the python to use python3.5 by executing the following command and selecting the appropriate option:
sudo update-alternatives --config python
Once done, check the python version by executing the command, python –version. It should print out something like Python 3.5.*.
pip install qiskit
The following screenshots represent the same:
Note some of the following libraries getting installed:
Save the following code in a file such as qc_hello.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'))
Run the above file with python command:
python qc_hello.py
Something such as following will get printed:
{'00': 527, '11': 497}
In case, you try with python program of earlier versions such as python2.7 (python2.7 qc_hello.py), you would get error like following:
Traceback (most recent call last): File "qc_hello.py", line 1, in <module> from qiskit import QuantumProgram ImportError: No module named qiskit
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…