'qiskit.remote'/'qiskit.basicsim'/'qiskit.ibmq' is not working

The backend showed me the output “<IBMBackend(‘ibm_brisbane’)>”.

from qiskit_ibm_runtime import QiskitRuntimeService
 
service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False, min_num_qubits= 4)

dev = qml.device('qiskit.remote', wires= 4, backend=backend)

After running the qml.device for hardware/simulators show me this error:-

Unexpected exception formatting exception. Falling back to standard exception
Traceback (most recent call last):
  File "C:\Users\kshit\anaconda3\Lib\site-packages\IPython\core\interactiveshell.py", line 3553, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "C:\Users\kshit\AppData\Local\Temp\ipykernel_29492\2406700381.py", line 1, in <module>
    dev = qml.device('qiskit.remote', wires= 4, backend=backend)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kshit\anaconda3\Lib\site-packages\pennylane\__init__.py", line 359, in device
  File "C:\Users\kshit\anaconda3\Lib\site-packages\importlib_metadata\__init__.py", line 184, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kshit\anaconda3\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\kshit\anaconda3\Lib\site-packages\pennylane_qiskit\__init__.py", line 17, in <module>
    from .aer import AerDevice
  File "C:\Users\kshit\anaconda3\Lib\site-packages\pennylane_qiskit\aer.py", line 21, in <module>
    from .qiskit_device_legacy import QiskitDeviceLegacy
  File "C:\Users\kshit\anaconda3\Lib\site-packages\pennylane_qiskit\qiskit_device_legacy.py", line 33, in <module>
    from .converter import QISKIT_OPERATION_MAP
  File "C:\Users\kshit\anaconda3\Lib\site-packages\pennylane_qiskit\converter.py", line 1229, in <module>
    ) -> qml.NoiseModel:
         ^^^^^^^^^^^^^^
AttributeError: module 'pennylane' has no attribute 'NoiseModel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\kshit\anaconda3\Lib\site-packages\IPython\core\interactiveshell.py", line 2144, in showtraceback
    stb = self.InteractiveTB.structured_traceback(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kshit\anaconda3\Lib\site-packages\IPython\core\ultratb.py", line 1435, in structured_traceback
    return FormattedTB.structured_traceback(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kshit\anaconda3\Lib\site-packages\IPython\core\ultratb.py", line 1326, in structured_traceback
    return VerboseTB.structured_traceback(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kshit\anaconda3\Lib\site-packages\IPython\core\ultratb.py", line 1173, in structured_traceback
    formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kshit\anaconda3\Lib\site-packages\IPython\core\ultratb.py", line 1088, in format_exception_as_a_whole
    frames.append(self.format_record(record))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kshit\anaconda3\Lib\site-packages\IPython\core\ultratb.py", line 970, in format_record
    frame_info.lines, Colors, self.has_colors, lvals
    ^^^^^^^^^^^^^^^^
  File "C:\Users\kshit\anaconda3\Lib\site-packages\IPython\core\ultratb.py", line 792, in lines
    return self._sd.lines
           ^^^^^^^^^^^^^^
  File "C:\Users\kshit\anaconda3\Lib\site-packages\stack_data\utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
                                               ^^^^^^^^^^^^^^
  File "C:\Users\kshit\anaconda3\Lib\site-packages\stack_data\core.py", line 698, in lines
    pieces = self.included_pieces
             ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kshit\anaconda3\Lib\site-packages\stack_data\utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
                                               ^^^^^^^^^^^^^^
  File "C:\Users\kshit\anaconda3\Lib\site-packages\stack_data\core.py", line 649, in included_pieces
    pos = scope_pieces.index(self.executing_piece)
                             ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kshit\anaconda3\Lib\site-packages\stack_data\utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
                                               ^^^^^^^^^^^^^^
  File "C:\Users\kshit\anaconda3\Lib\site-packages\stack_data\core.py", line 628, in executing_piece
    return only(
           ^^^^^
  File "C:\Users\kshit\anaconda3\Lib\site-packages\executing\executing.py", line 164, in only
    raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0

I have a newer version of pennylane.qiskit and pennylane :-

Name: PennyLane
Version: 0.38.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: GitHub - PennyLaneAI/pennylane: 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.
Author:
Author-email:
License: Apache License 2.0
Location: C:\Users\kshit\anaconda3\Lib\site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, toml, typing-extensions
Required-by: PennyLane-Cirq, PennyLane-Honeywell, PennyLane-IonQ, PennyLane-qiskit, PennyLane-Rigetti, PennyLane_Lightning

Platform info: Windows-10-10.0.22631-SP0
Python version: 3.11.7
Numpy version: 1.26.4
Scipy version: 1.14.1
Installed devices:

  • default.clifford (PennyLane-0.38.0)
  • default.gaussian (PennyLane-0.38.0)
  • default.mixed (PennyLane-0.38.0)
  • default.qubit (PennyLane-0.38.0)
  • default.qubit.autograd (PennyLane-0.38.0)
  • default.qubit.jax (PennyLane-0.38.0)
  • default.qubit.legacy (PennyLane-0.38.0)
  • default.qubit.tf (PennyLane-0.38.0)
  • default.qubit.torch (PennyLane-0.38.0)
  • default.qutrit (PennyLane-0.38.0)
  • default.qutrit.mixed (PennyLane-0.38.0)
  • default.tensor (PennyLane-0.38.0)
  • null.qubit (PennyLane-0.38.0)
  • cirq.mixedsimulator (PennyLane-Cirq-0.36.0.post0)
  • cirq.pasqal (PennyLane-Cirq-0.36.0.post0)
  • cirq.qsim (PennyLane-Cirq-0.36.0.post0)
  • cirq.qsimh (PennyLane-Cirq-0.36.0.post0)
  • cirq.simulator (PennyLane-Cirq-0.36.0.post0)
  • honeywell.hqs (PennyLane-Honeywell-0.34.1)
  • ionq.qpu (PennyLane-IonQ-0.36.0.post0)
  • ionq.simulator (PennyLane-IonQ-0.36.0.post0)
  • lightning.qubit (PennyLane_Lightning-0.38.0)
  • qiskit.aer (PennyLane-qiskit-0.38.1)
  • qiskit.basicaer (PennyLane-qiskit-0.38.1)
  • qiskit.basicsim (PennyLane-qiskit-0.38.1)
  • qiskit.remote (PennyLane-qiskit-0.38.1)
  • rigetti.numpy_wavefunction (PennyLane-Rigetti-0.36.0.post0)
  • rigetti.qpu (PennyLane-Rigetti-0.36.0.post0)
  • rigetti.qvm (PennyLane-Rigetti-0.36.0.post0)
  • rigetti.wavefunction (PennyLane-Rigetti-0.36.0.post0)

Hi @Kshitij_Dave, this looks like an issue with the environment where you’re running your code.

I recommended that you create a new virtual environment to avoid any installation issues. You can create a virtual environment with Conda and install PennyLane-Qiskit as follows:

  1. Install Miniconda following the instructions here.
  2. Open your terminal (mac) or command line (Windows).
  3. Create a new Conda environment with: conda create --name <name_of_your_environment> python=3.10
  4. Activate the environment with: conda activate <name_of_your_environment>
  5. Install PennyLane-Qiskit with: python -m pip install pennylane-qiskit
  6. Install other useful packages with: python -m pip install jupyter matplotlib

Note that you will be installing 3 packages here: PennyLane-Qiskit, Jupyter, and Matplotlib. Also, note that where it says <name_of_your_environment> you can choose any name that you want.


Once you have your environment I would recommend running something like the code below. Make sure to use wires=127 since IBM’s devices actually have 127 qubits.

import pennylane as qml
from qiskit_ibm_runtime import QiskitRuntimeService
QiskitRuntimeService.save_account(channel="ibm_quantum", token=token, overwrite=True)

service = QiskitRuntimeService()
backend = service.backend(name= 'ibm_sherbrooke')

dev = qml.device('qiskit.remote', wires=127, backend=backend)

Note that you might get a PennyLaneDeprecationWarning the first time you run this code, this is normal.

Let me know if this solves your issue!