Pennylane lightning.qubit is not working

Hi,

I am trying to testing my code for lightning.qubit, but it is not working for some reason. Currently, I created have tried conda with python 3.11 and 3.12 and I tried to install from pip and compile from source for both version.

Here’s my version info:

Name: PennyLane
Version: 0.40.0
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page: https://github.com/PennyLaneAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: /u/home/h/haochen/miniconda3/envs/penny311/lib/python3.11/site-packages
Requires: appdirs, autograd, autoray, cachetools, diastatic-malt, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, tomlkit, typing-extensions
Required-by: PennyLane_Lightning

Platform info:           Linux-3.10.0-1160.108.1.el7.x86_64-x86_64-with-glibc2.17
Python version:          3.11.11
Numpy version:           2.0.2
Scipy version:           1.15.2
Installed devices:
- default.clifford (PennyLane-0.40.0)
- default.gaussian (PennyLane-0.40.0)
- default.mixed (PennyLane-0.40.0)
- default.qubit (PennyLane-0.40.0)
- default.qutrit (PennyLane-0.40.0)
- default.qutrit.mixed (PennyLane-0.40.0)
- default.tensor (PennyLane-0.40.0)
- null.qubit (PennyLane-0.40.0)
- reference.qubit (PennyLane-0.40.0)
- lightning.qubit (PennyLane_Lightning-0.40.0)

and my system version

Linux login1 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
CentOS Linux release 7.9.2009 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

CentOS Linux release 7.9.2009 (Core)
CentOS Linux release 7.9.2009 (Core)

And below is the error

/u/home/h/haochen/miniconda3/envs/penny311/lib/python3.11/site-packages/pennylane_lightning/lightning_qubit/lightning_qubit.py:58: UserWarning: No module named 'pennylane_lightning.lightning_qubit_ops'
  warn(str(ex), UserWarning)
/u/home/h/haochen/miniconda3/envs/penny311/lib/python3.11/site-packages/pennylane_lightning/lightning_qubit/_adjoint_jacobian.py:29: UserWarning: No module named 'pennylane_lightning.lightning_qubit_ops'
  warn(str(ex), UserWarning)
/u/home/h/haochen/miniconda3/envs/penny311/lib/python3.11/site-packages/pennylane_lightning/lightning_qubit/_measurements.py:26: UserWarning: No module named 'pennylane_lightning.lightning_qubit_ops'
  warn(str(ex), UserWarning)
/u/home/h/haochen/miniconda3/envs/penny311/lib/python3.11/site-packages/pennylane_lightning/lightning_qubit/_state_vector.py:26: UserWarning: No module named 'pennylane_lightning.lightning_qubit_ops'
  warn(str(ex), UserWarning)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/u/home/h/haochen/miniconda3/envs/penny311/lib/python3.11/site-packages/pennylane/devices/device_constructor.py", line 263, in device
    dev = plugin_device_class(*args, **options)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/u/home/h/haochen/miniconda3/envs/penny311/lib/python3.11/site-packages/pennylane_lightning/lightning_qubit/lightning_qubit.py", line 244, in __init__
    raise ImportError(
ImportError: Pre-compiled binaries for lightning.qubit are not available. To manually compile from source, follow the instructions at https://docs.pennylane.ai/projects/lightning/en/stable/dev/installation.html.

Many thanks!

Hi, @harry! Welcome to the forum :partying_face:
Ah! I was running into this problem yesterday on mi mac machine using python 3.13.0. I fixed it by creating a fresh virtual environment with pyenv with python 3.11.0. Then, I simply install pennylane using python -m pip install pennylane
My colleague, Catalina, has seen this error in the past and here is what she suggests from another forum post.
I would probably try to follow those suggestions and/or see if using another tool to manage virtual environments works better.
Let us know if any of this works and if not, we’ll keep trying to help you.

1 Like