I started using Qiskit with their official tutorial (Sezon 1) and I got a few bugs with the same code, at the beginning I just had to install pylatexenc but then I had "module 'qiskit.circuit' has no attribute 'draw'" error, this is not true as I used it before, I found some things about it on GitHub but no clear solution, my code is:
from qiskit import *
qr = QuantumRegister(2)
cr = ClassicalRegister(2)
circuit = QuantumCircuit(qr, cr)
circuit = QuantumCircuit(qr, cr)
circuit.draw()
[it worked, output:
q0_0:
q0_1:
c0: 2/
]
circuit.h(qr[0])
[output: <qiskit.circuit.instructionset.InstructionSet at 0x12dc159de50>]
circuit.draw(output= 'mpl')
error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-4b6f233c71ed> in <module>
----> 1 circuit.draw(output= 'mpl')
AttributeError: module 'qiskit.circuit' has no attribute 'draw'
I use jupiter and Python 3.8, if version is wrong please tell me what version should I use and where do I download it, also, the output in first circuit.draw()
is for some reason different than in original video
After installing pip install pylatexenc
you must restart your notebook kernel and run again. It worked for me!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With