# Google Colab - ImportError: The class MatplotlibDrawer needs pylatexenc

When I run the following command

qc.draw(output='mpl')


for my circuit qc, I get this error:

ImportError: The class MatplotlibDrawer needs pylatexenc


How do I address this issue? Below an image of my problem

Update ------
!pip install pylatexenc ?.

The installation attempt (was successful and the installed pylatexenc has version 2.7.)

• Have you tried installing pylatexenc with whichever package manager you are using? – Rammus Sep 13 at 11:21
• Thanks for the image. You have the latest version of Qiskit. – user9318 Sep 16 at 11:57
• +1 vey good! The fact that you are using "google colab" is very important to know. I've never used it before. I'll get back to you as soon as I find more information. – user9318 Sep 16 at 12:09
• Meanwhile, I think it would be a good idea if you post your question on stackoverflow and tag google-colaboratoy. – user9318 Sep 16 at 12:19
• Check out this stackoverflow.com/questions/51342408/…. Also when you run the line !pip install pylatexenc in your notebook what is the output? Does it run without problem? – user9318 Sep 16 at 12:27

It's an issue with latest Qiskit I've noticed. Use following command to downgrade it to previous version(0.16.1 specifically) for the time being.

!pip install qiskit==0.16.1

• yes It is working on v0.16.1 but problem is with v0.21.0 I think this problem is happning on notebooks but not on IDLE or pycharm @dushyanth – quantum_boy Sep 18 at 10:37

The 0.15.2 is actually the version of your qiskit-terra package not Qiskit itself.
I'd suggest you to check the version by qiskit.__qiskit_version__. See the documentation.

If all packages have the latest version, you simply need to install pylatexenc in the same env where your Qiskit has been installed. Just by typing pip install pylatexenc in terminal!

In case you don't have the latest version of Qiskit. You need to upgrade it first by pip install qiskit --upgrade and then install pylatexenc.

Update
%pip install pylatexenc
use %matplotlin inline before executing draw('mpl') here is the link for more info
• Line magic function %matplotlin not found. It shows this – dushyanth Sep 18 at 10:40
• @dushyanth, There is a type it should be %matplotlib inline. – user9318 Sep 18 at 13:49