qBraid environments are simply Python virtual environments in disguise. There are two directories where qBraid environment can be found. One at the system level, and one at the local / user level:


The environments at the system level are reset each time you launch Lab, so any changes made to these environments will not persist between sessions. The user level environments are yours to modify: any and all changes you make to these environments will still be there the next time to launch Lab. The qBraid CLI provides convenient short-cuts to activate and install packages into your qBraid environments, however all of the traditional commands to activate and manipulate Python venvs still apply. For example, you can activate an environment using the source command:

$ source ~/.qbraid/environments/<slug>/pyenv/bin/activate

If you’re working in terminal, you don’t specifically need to activate a qBraid environment, as you can just specify the full path to that environment’s Python interpreter when invoking Python, e.g. /<path-to-venv>/bin/python. The same is true for pip commands. So if you are attempting to install new packages into a qBraid environment from terminal or inside a notebook, make sure to use the full pip path.

Simply running pip install ... will default to /opt/conda/bin/pip, which will cause dependency conflicts, and the installed packages will be overridden the next time you launch lab.

Install package

From Launcher, under “Other”, click on Terminal. By default, your qBraid terminal opens using Python (and pip) from /opt/conda/bin. Packages that are installed directly at this top-level will not persist between sessions. Instead, use the qBraid CLI to list your environments,

$ qbraid envs list
# qbraid environments:

default                        /opt/.qbraid/environments/qbraid_000000
qsharp                         /opt/.qbraid/environments/qsharp_b54crn
qbraid_sdk                     /home/jovyan/.qbraid/environments/qbraid_sdk_9j9sjy
qiskit                         /home/jovyan/.qbraid/environments/qiskit_9y9siy

activate an environment, and perform your pip installs from there. For example, installing pytket into the qiskit environment:

$ qbraid envs activate qiskit
$ python -m pip install pytket
$ deactivate