2
$\begingroup$

After executing the proceeding code blocks, when I try to copy the same code from Qiskit textbook on my jupyter notebook, I get the error as

QiskitError: 'Data for experiment "circuit-109" could not be found.'

simulator = qiskit.Aer.get_backend('qasm_simulator')

circuit = QuantumCircuit(1, simulator, 100)
print('Expected value for rotation pi {}'.format(circuit.run([np.pi])[0]))
circuit._circuit.draw(
)

Please suggest:

<ipython-input-23-06b09ff4dd69> in <module>
      2 
      3 circuit = QuantumCircuit(1, simulator, 100)
----> 4 print('Expected value for rotation pi {}'.format(circuit.run([np.pi])[0]))
      5 circuit._circuit.draw()

<ipython-input-22-e6eb9c91d6f9> in run(self, thetas)
     28                         parameter_binds = [{self.theta: theta} for theta in thetas])
     29         job = self.backend.run(qobj)
---> 30         result = job.result().get_counts(self._circuit)
     31 
     32         counts = np.array(list(result.values()))

~\anaconda3\lib\site-packages\qiskit\result\result.py in get_counts(self, experiment)
    261         dict_list = []
    262         for key in exp_keys:
--> 263             exp = self._get_experiment(key)
    264             try:
    265                 header = exp.header.to_dict()

~\anaconda3\lib\site-packages\qiskit\result\result.py in _get_experiment(self, key)
    368 
    369             if len(exp) == 0:
--> 370                 raise QiskitError('Data for experiment "%s" could not be found.' %
    371                                   key)
    372             if len(exp) == 1:

QiskitError: 'Data for experiment "circuit-109" could not be found.'```
$\endgroup$
2
3
$\begingroup$

After checking, this issue was introduced in the last qiskit-terra release. The textbook should be fixed to adjust the get_counts, as already reported here.

In any case, the workaround for now is removing self._circuit from result = job.result().get_counts(self._circuit) (in QuantumCircuit.run method).

class QuantumCircuit:
    ...

    def run(self, thetas):
        ...
        job = self.backend.run(qobj)
        result = job.result().get_counts()  # <- here
        ...
$\endgroup$
2
  • $\begingroup$ Thank you so much sir. The error is gone. $\endgroup$
    – user14924
    Apr 11 at 7:23
  • $\begingroup$ thanks for the answer to this bug! $\endgroup$
    – user665997
    Jun 14 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.