Qiskit problem with visualization in libray not functioning

49 views Asked by At

This is IBM quantum simulator with the help of Python and qiskit code. But i am stuck[enter image description here]enter image description here(https://i.stack.imgur.com/BBwR5.png)

I just want to know why this is not working.

There is a youtube video on it but still need help.

1

There are 1 answers

0
Matthew Treinish On

The fundamental issue is a mistake in your source code. In cell 42 you are collecting the result from the simulator execution by calling .result() and then not setting the return to the variable result that you expect in cell 57. It looks like you have imported the qiskit's result module (something like from qiskit import result) above in a cell that's not visible which is getting accessed when you run result.get_counts() which is the root cause of you error. To avoid the conflict and fix your issue I would change cell 42 to be something like:

exec_result = execute(circuit, backend=simulator).result()

and then change cell 57 to be:

counts = exec_result.get_counts()
plot_histogram(counts)

This should fix the specific error your seeing in this case.