Search code examples
python-3.xjupyter-notebookquantum-computing

Why am I getting "TypeError" for Device function in pennylane?


I am doing basic coding for rotation of qubit as given in the Xanadu Pennylane tutorial. I have installed pennylane and tried running the code but I am getting TypeError.

I also tried with

dir(qml)

This gave me a list of built-in functions in qml where Device is already present.

Here goes the actual code:

from pennylane import numpy as np
import pennylane as qml

dev1 = qml.Device('default.qubit', wires=1)

All I am getting is the TypeError.

TypeError: Can't instantiate abstract class Device with abstract methods apply, author, expval, name, observables, operations, pennylane_requires, reset, short_name, version


Solution

  • I have not tried running this code myself, but looking at the qubit rotation tutorial and example, both of them use

    dev1 = qml.device('default.qubit', wires=1)
    

    (with device starting with lowercase d)