Hii Pennylane team
I am Sri, kinda new to pennylane. I installed pennylane using “pip install pennylane” Whenever I call in lightning.qubit, I am getting an installation error. Please refer to attached image.
I even looked at previous answers on pennylane installation errors. I created a new env using conda with python 3.12, yet the error persists.
- If I use default.qubit and print the qml.about (), I could see Pennylane-lightning is installed.
import pennylane as qml
from pennylane import qchem
from pennylane import numpy as np
dev = qml.device("lightning.qubit", wires=2)
qml.about()
Hi @Srivathsan_Sundar , welcome to the Forum!
It looks like something went wrong in the installation. Are you able to create a new virtual environment with venv? In some (rare) cases, Conda doesn’t work well.
Here are some steps to create a virtual environment with venv:
-
Download Python 3.10 or newer here (3.11 recommended).
-
Double-click on the .pkg file (Mac) or .exe file (Windows).
-
Double-click on the Install Certificates.command file. It will open a terminal. You can close it after it says “process completed”.
-
Open your terminal/command line.
-
Create the directory for your virtual environment with: mkdir ~/.virtualenvs
-
Create a new virtual environment with:
python3.X -m venv ~/.virtualenvs/new_venv
where X is the version of Python you installed. E.g. if you installed Python 3.11 then start with python3.11
You can change new_venv
to whatever name you want for your environment.
-
Activate the environment with:
source ~/.virtualenvs/new_venv/bin/activate
-
Install PennyLane with: python -m pip install pennylane
-
Install other useful packages such as Jupyter and Matplotlib with:
python -m pip install jupyter matplotlib
-
Write jupyter notebook
in your terminal/command line and you will be ready to create programs using PennyLane.
Every time you want to use PennyLane make sure to open a new terminal/command line, activate the environment with step 7, and open a Jupyter notebook with step 10.
If you prefer to use Python scripts instead of Jupyter notebooks that should work too, so steps 9 and 10 are optional.
Let us know if this solves the issue!
Hii Catalina
Thanks for immediate response and also for providing detailed procedure. I created a new environment using venv with python3.11 and followed the procedure you mentioned. I got the same error again. Please find the attached screenshots. Also wanted to highlight my mac is old, currently using MacOS BigSur 11.7.10. Would that be an issue ?
Additionally, I tried doing the same procedure in the university cluster, got in the same error. Please help me in resolving this issue.
Hi @Srivathsan_Sundar ,
Thanks for sharing this info. I’m not sure what’s going on but I’ve asked someone else in our team to take a look. We’ll get back to you by early next week.
If this is blocking work you can use Google Colab or qBraid in the meantime while we figure out the issue with your local installation. In these online services you just need to run !pip install pennylane
in the first cell.
Hi @Srivathsan_Sundar ,
It looks like the issue is due to your MacOS version. We no longer support MacOS 11 (as of PennyLane v0.39).
Here are some options of what you can do:
- Use Google Colab or qBraid
- Upgrade MacOS to 13.0 or higher (the latest MacOS version is at 15.x, so we are still supporting several releases back).
If the options above don’t work for you then you can try the options below (although they’re not ideal and we may not be able to provide support):
- Build manually from source (not guaranteed to work)
- Use the older PennyLane and Lightning versions supporting MacOS 11 (
pip install pennylane==0.38 pennylane-lightning==0.38
should work on your machine)
Let us know if you manage to get one of these options working for you!
Dear @Catalina
Thanks for highlighting the fact that MacOS version is the issue here. I tried in with 0.38 version of pennylane, lightning.qubit is working in my Mac.
Another issue is that, I tried to install pennylane in a linux based university cluster. I followed the same procedure as you mentioned before. I tried both 0.38 and latest version, both showed up same error.
Linux based cluster is independent of my present MacOS system. Can you please help me resolve this issue when it comes to cluster ?
Thanks for confirming that it now works on your Mac @Srivathsan_Sundar !
Installing on a cluster can be tricky. In principle pip install pennylane
should be enough but every cluster is different so you may need to install from source if a normal pip install isn’t working.
You can find the instructions to install from source in the lightning docs. You probably just need to run the first line there instead of the development installation. Please let us know if you have any issues or questions.
Dear Catalina
Yeah, installing on the cluster is bit tricky.
pip install pennylane
command isn’t working. I am getting the same error message. I just ran the first line of install from source. The error is still present.
Thanks for confirming @Srivathsan_Sundar .
Can you please copy-paste here the exact code that you ran in the cluster? PL_BACKEND= ...
Also, can you confirm that you have a C++ compiler such as g++
, clang++
, or MSVC
?