AttributeError: 'QNode' object has no attribute 'draw'

Hello. I am new to PennyLane and Quantum Computing in general. I was using some sample code and am getting an error that I have not been able to find a solution to. I have put the code below as well as the error. Thanks in adance.

Code:
import pennylane as qml
from pennylane import numpy as np
from pennylane.templates.embeddings import BasisEmbedding

dev = qml.device(‘default.qubit’, wires=6)

@qml.qnode(dev)
def circuit(data):
for i in range(6):
qml.Hadamard(i)
for i in range(len(data)):
BasisEmbedding(features=data[i], wires=range(6),do_queue=True)
return qml.state()

data=[[1,0,1,1,1,0],
[1,0,0,0,0,1]]

circuit(data)

print(circuit.draw(show_all_wires=True))

Error:

AttributeError Traceback (most recent call last)
/tmp/ipykernel_50/2114460403.py in <cell line: 23>()
21 circuit(data)
22
—> 23 print(circuit.draw(show_all_wires=True))
24

AttributeError: ‘QNode’ object has no attribute ‘draw’

Hi @BillWisotsky, welcome to the forum!

I recommend that you try using our new matplotlib drawer. You can use it by replacing your print line for:

qml.draw_mpl(circuit)(data)

Please let me know if this solves your problem!

This fixed my problem. Thanks so much for your guidance.

I’m glad this helped! Enjoy using PennyLane! :smiley:

Thanks, so far so good. Agains thanks for the help.