Installation and dependencies

Dependencies

PennyLane requires the following libraries be installed:

The following Python packages are hard dependencies, and will automatically be installed alongside PennyLane:

The following Python packages are optional:

  • openfermionpyscf, for the non-differentiable backend of the qml.qchem module

  • matplotlib: for qml.draw_mpl and associated code

  • quimb: for the default.tensor device

  • pyzx: for qml.transforms.to_zx and qml.transforms.from_zx

  • stim: for default.clifford

  • openqasm3 and antlr3_python3_runtime: for qml.from_qasm3

  • kahypar and opt_einsum for qcut

  • cvxopt``for ``qml.kernels.closest_psd_matrix

If you currently do not have Python 3 installed, we recommend Anaconda for Python 3, a distributed version of Python packaged for scientific computation.

Interface dependencies

For development of the TensorFlow, PyTorch, and JAX interfaces, there are additional requirements which must be installed manually:

  • JAX interface: jax and jaxlib == 0.6.0

  • PyTorch interface: pytorch

  • TensorFlow interface: tensorflow < 2.17

Installation

For development purposes, it is recommended to install PennyLane source code using development mode:

git clone https://github.com/PennyLaneAI/pennylane
cd pennylane
pip install -e .

The -e flag ensures that edits to the source code will be reflected when importing PennyLane in Python.

Note

Due to the use of entry points to install plugins, changes to PennyLane device class locations or shortnames requires pip install -e . to be re-run in the plugin repository for the changes to take effect.

Apart from the core packages needed to run PennyLane, some extra packages need to be installed for several development processes, such as linting, testing, and pre-commit quality checks. Those can be installed easily via pip:

pip install -r requirements-dev.txt