qiskit-textbook icon indicating copy to clipboard operation
qiskit-textbook copied to clipboard

Chapter 1: The atoms of computation

Open a-vanderbilt opened this issue 2 years ago • 1 comments

Describe the bug

The second code exercise in "Your first quantum circuit" does not run, because the "QuantumCircuit" module is not being imported. Adding from qiskit import QuantumCircuit to the code editor fixes the error.

To Reproduce

Run the code in the editor.

Expected behavior

The code should run and produce output demonstrating the code's functionality.

Version info

Beta Textbook

For website problems please state device / OS / browser.

MacBook Air M1 / macOS Monterrey/ Safari 15.4

Screenshots

Screen Shot 2022-05-20 at 11 09 24 PM Screen Shot 2022-05-20 at 11 14 08 PM

Additional context

No response

a-vanderbilt avatar May 21 '22 03:05 a-vanderbilt

Hey! So essentially each topic/section in a chapter say "The atoms of computation" is a Jupyter notebook and hence the code present in all the cells is run in the same(single) environment. It is stated clearly at the beginning of the Atoms of computation section that you will have to run the cell which contains all the imports(including that of QuantumCircuit) to be able to run the rest of the code in that section(image attached below). So the problem that you have encountered might probably be because you either forgot to run the import cell or you would have run it long back and the kernel would have died as a result of non-activity which is probably why the imports have not been reflected. Hope that helps and please correct me if I'm wrong :)

Atoms of computation answering a doubt

Haemanth-V avatar May 30 '22 10:05 Haemanth-V