Run pennylane-qulacs error,please [cry]……

i am a green hand…this problem make me crazy…please help me!!
when i run this code,it has something wrong:
import pennylane as qml
dev = qml.device(‘qulacs.simulator’, wires=2)

ModuleNotFoundError Traceback (most recent call last) [c:\Users\ming\Desktop\qaoa\max-cut.ipynb](file:///C:/Users/ming/Desktop/qaoa/max-cut.ipynb) 单元格 3 line 3 1 import pennylane as qml ----> 3 dev = qml.device(‘qulacs.simulator’, wires=2) File [d:\download\Anaconda\envs\xming\Lib\site-packages\pennylane_init_.py:346](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pennylane/init.py:346), in device(name, *args, **kwargs) [343](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pennylane/init.py:343) options.update(kwargs) [345](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pennylane/init.py:345) # loads the device class → [346](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pennylane/init.py:346) plugin_device_class = plugin_devices[name].load() [348](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pennylane/init.py:348) if hasattr(plugin_device_class, “pennylane_requires”) and Version( [349](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pennylane/init.py:349) version() [350](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pennylane/init.py:350) ) not in SimpleSpec(plugin_device_class.pennylane_requires): [351](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pennylane/init.py:351) raise DeviceError( [352](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pennylane/init.py:352) f"The {name} plugin requires PennyLane versions {plugin_device_class.pennylane_requires}, " [353](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pennylane/init.py:353) f"however PennyLane version {version} is installed." [354](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pennylane/init.py:354) ) File [d:\download\Anaconda\envs\xming\Lib\site-packages\pkg_resources_init_.py:2518](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pkg_resources/init.py:2518), in EntryPoint.load(self, require, *args, **kwargs) [2516](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pkg_resources/init.py:2516) if require: [2517](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pkg_resources/init.py:2517) self.require(*args, **kwargs) → [2518](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pkg_resources/init.py:2518) return self.resolve() File [d:\download\Anaconda\envs\xming\Lib\site-packages\pkg_resources_init_.py:2524](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pkg_resources/init.py:2524), in EntryPoint.resolve(self) [2520](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pkg_resources/init.py:2520) def resolve(self):

—> [34](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pennylane_qulacs/qulacs_device.py:34) import qulacs.gate as gate [35](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pennylane_qulacs/qulacs_device.py:35) from qulacs import QuantumCircuit, QuantumState, Observable [37](file:///D:/download/Anaconda/envs/xming/Lib/site-packages/pennylane_qulacs/qulacs_device.py:37) from ._version import version ModuleNotFoundError: No module named ‘qulacs’

i want to pip install qulacs in anaconda prompt ,it appear:
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for qulacs
Failed to build qulacs
ERROR: Could not build wheels for qulacs, which is required to install pyproject.toml-based projects

I have pip install pennylane-qulacs, but when i run this program it still say No module named ‘qulacs’.my python,pennylane,and pip is the newest.

how can i try?please tell me ,thank you very much.

Hello @ming, welcome to the forum!

This seems to be more of an issue with qulacs rather than PennyLane itself. You do need to pip install qulacs before you can use pennylane-qulacs. Here are some options for you:

  • Install qulacs directly from the source using pip install git+https://github.com/qulacs/qulacs.git
  • Or, use a Google Colab notebook. I was able to succesfully install qulacs and pennylane-qulacs using !pip install qulacs and !pip install pennylane-qulacs there.

Hope this helps,

Alvaro

thank you for you reply.i try lots of methods.And now i think the problem is the version.my other computer which install python=3.11.5 can use qulacs successfully,this computer python=3.12.0,maybe qulacas can only suit the pyhon3.11……Best wishes for you!

1 Like

Thank you @ming glad you were able to figure it out! This is really great to know in case someone encounters the same problem in the future :raised_hands: !

1 Like