Home » ImportError: no module named pylab

ImportError: no module named pylab

To solve python error: no module named pylab error follow below methods. Given below is the error log


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pylab

How to solve python error: no module named pylab ?

Refer to the given methods to solve the issue.

Method 1:

To get pylab, you’ll need to install numpy, scipy, and matplotlib. You may install them in Ubuntu by using the following command:

sudo apt-get install python-numpy python-scipy python-matplotlib

If you installed Python from source, you must install these packages using pip. It’s worth noting that you may need to install additional dependencies, as well as numpy before the other two.

Method 2 :

So if the above installations of numpy or scipy don’t work, pylab was unable to recognize the matplotlib. Then use the below code snippet to import the pylab from the matplotlib.

from matplotlib import pylab
from pylab import *

Hope the above solution works.

Also read : UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xef in position