You need python3
and its venv
module – if you don't have it, your package manager (apt-get
, yum
, ...) should be of help.
Create a separate Python environment. This is where the dependencies live; you can just delete it when you don't need it anymore.
$ # run this in your terminal
$ PLAYGROUND_PATH="~/qc_playground" # you can change this to another folder if you want
$ mkdir -p $PLAYGROUND_PATH
$ python3 -m venv $PLAYGROUND_PATH/venv
$ source $PLAYGROUND_PATH/venv/bin/activate
$ pip install qiskit
Download the base_playground.py
above. Ideally put it into PLAYGROUND_PATH
, but any other path works as well. For example:
$ # pick either one as available
$ wget https://gist.githubusercontent.com/maxfischer2781/61c5e6e7709c199bebc9a72f25dd403a/raw/329c304ebbe2be22971aabd7325998e2292c6398/base_playground.py -P $PLAYGROUND_PATH/
$ curl https://gist.githubusercontent.com/maxfischer2781/61c5e6e7709c199bebc9a72f25dd403a/raw/329c304ebbe2be22971aabd7325998e2292c6398/base_playground.py -o $PLAYGROUND_PATH/base_playground.py
Whenever you want to play around with qiskit, run source $PLAYGROUND_PATH/venv activate
in the shell.
This changes the python
command to point to your Qiskit Python environment.
To run the example, execute it after activating the environment:
python $PLAYGROUND_PATH/base_playground.py