PennyLane-Lightning requires Python version 3.7 and above. It can be installed using pip:

$ pip install pennylane-lightning

To build PennyLane-Lightning from source you can run

$ pip install pybind11 pennylane-lightning --no-binary :all:

A C++ compiler such as g++, clang, or MSVC is required. On Debian-based systems, this can be installed via apt:

$ sudo apt install g++

The pybind11 library is also used for binding the C++ functionality to Python.

Alternatively, for development and testing, you can install by cloning the repository:

$ git clone
$ cd pennylane-lightning
$ pip install -r requirements.txt
$ pip install -e .

Note that subsequent calls to pip install -e . will use cached binaries stored in the build folder. Run make clean if you would like to recompile.

You can also pass cmake options with build_ext:

$ python3 build_ext -i --define="ENABLE_OPENMP=OFF;ENABLE_NATIVE=ON"

and install the compilied library with

$ python3 develop

GPU support

For GPU support, PennyLane-Lightning-GPU can be installed by providing the optional [gpu] tag:

$ pip install pennylane-lightning[gpu]

For more information, please refer to the PennyLane Lightning GPU documentation.


To test that the plugin is working correctly you can test the Python code within the cloned repository:

$ make test-python

while the C++ code can be tested with

$ make test-cpp

CMake Support

One can also build the plugin using CMake:

$ cmake -S. -B build
$ cmake --build build

To test the C++ code:

$ mkdir build && cd build
$ make


Compile on Windows with MSVC

You can also compile Pennylane-Lightning on Windows using Microsoft Visual C++ compiler. You need cmake and appropriate Python environment (e.g. using Anaconda).

We recommend to use [x64 (or x86)] Native Tools Command Prompt for VS [version] for compiling the library. Be sure that cmake and python can be called within the prompt.

$ cmake --version
$ python --version

Then a common command will work.

$ pip install -r requirements.txt
$ pip install -e .

Note that OpenMP and BLAS are disabled in this setting.