# 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? Sep 13 '20 at 11:21
• Thanks for the image. You have the latest version of Qiskit. Sep 16 '20 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. Sep 16 '20 at 12:09
• Meanwhile, I think it would be a good idea if you post your question on stackoverflow and tag google-colaboratoy. Sep 16 '20 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? Sep 16 '20 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 Sep 18 '20 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

• Yes I have done exactly the same but still showing same error. please see my question again this time I also have provided the Image. @user9318 Sep 16 '20 at 11:58
• I appreciate your effort you did for this problem brother but it is still not working. And I am taking your advise to post it on Stackoverflow. Thaknyou @user9318 Sep 16 '20 at 14:24
• @quantum_boy did you find a way around that? Sep 17 '20 at 14:36
• No, Do you have solution?@dushyanth Sep 17 '20 at 14:38
• I just found solution read my answer and thanks for you effort and time @user9318 Sep 17 '20 at 23:56

use %matplotlin inline before executing draw('mpl') here is the link for more info

• Line magic function %matplotlin not found. It shows this Sep 18 '20 at 10:40
• @dushyanth, There is a type it should be %matplotlib inline. Sep 18 '20 at 13:49
• %matplotlib inline even this doesn't fix it. I get the same error mentioned in the question ImportError: The class MatplotlibDrawer needs pylatexenc. Sep 19 '20 at 4:34

In my case, running same command ( with !pip install pylatexenc) inside the jupyter notebook solved the issue!

• Welcome on the QC SE! I suggest to write more about, how your answer works. Dec 8 '20 at 10:08