Install Qiskit
This is an instruction for linux (Ubuntu 22.04).
For MacOS or Windows, please see the instructions here.
-
Make sure you have python3 command available.
-
Create a directory for your project.
mkdir qiskit-project
cd qiskit-project
-
Create a directory under qiskit-project.
mkdir .venv
-
Run the following command, you may need to install python3.10-venv package.
python3 -m venv .venv/
-
Activate your new environment.
source .venv/bin/activate
Now your terminal prompt should be prefixed by "(.venv)".
-
Use pip to install qiskit, qiskit-aer (for simulators) and matplotlib (for visualization).
pip install qiskit qiskit-aer matplotlib
-
You can run
pip list
to see the active packages in your virtual environment.
Run Qiskit code on local simulators (Ubuntu 22.04)
We assume you are still in the the same virtual environment (.venv).
- Download the this python file and run it with the following command.
python3 bell.py
If everything is setting up correctly, you should see
an output
like {'00': 0.4845, '11': 0.5155}, a generated "my_circuit.png" file for
the output, and
a printed ascii circuit for bell00 state.
Note
- Once you have gone through the installation process. Each time you want to run your program,
you will need to activate the python virtual environment by doing the following.
source .venv/bin/activate
Your python code should always be ran inside this environment.