简体   繁体   中英

Omitting imports in qiskit

I'm running simple programs in the online Qiskit interface. Earlier today, when I forgot to import QuantumRegister, I got an error message. But later, I started a new file, erased all the imports that are provided by default, and typed code without any imports. But the code makes reference to transpile, numpy, and Aer. To my surprise, the code runs without imports. Are explicit imports for numpy, transpile, Aer, and BasicAer optional?

I think I figured it out. When you're running a Jupyter notebook, as soon as you run a cell with an import, that import stays in effect for everything else you do in the notebook. To un-import everything (so you can experiment with what you need and don't need to import), you look for the Restart option (at the top of the notebook) and restart the Kernel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM