circuit.draw(output='mpl') gives error "The 'pylatexenc' library is required to use 'MatplotlibDrawer"

67 views Asked by At

I can't run the following command because I get an error

circuit.draw(output='mpl')

Error text:

MissingOptionalLibraryError: "The 'pylatexenc' library is required to use 'MatplotlibDrawer'. You can install it with 'pip install pylatexenc'.

my code :

!pip inatall qiskit
!pip install pylatexenc
from qiskit import *
%matplotlib inline
from pylatexenc import *

qr = QuantumRegister(2)
cr = ClassicalRegister(2)
circuit = QuantumCircuit(qr,cr)

circuit.draw(output='mpl')
1

There are 1 answers

1
physicino On BEST ANSWER

This has happend to me about a month ago. The thing that I suggest you to do is to once uninstall your Qiskit with

pip uninstall qiskit

in your kernel. I mostly use the Pyhton version 10.11 which is more compatible for to use Qiskit and Qutip together. Maybe it is a personal experience, but when I work with Python 12, I encounter weird errors.