Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python error: no module named pylab

I am new to Python and want to use its plot functionality to create graphs. I am using ubuntu 12.04. I followed the Python installation steps from http://eli.thegreenplace.net/2011/10/10/installing-python-2-7-on-ubuntu/ but when I do

from pylab import * 

I am getting this error

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

My Python version is python 2.7. Can anybody tell me what I am missing here?

like image 798
Sadiksha Gautam Avatar asked Jun 09 '12 23:06

Sadiksha Gautam


People also ask

What is PyLab in Python?

PyLab is a Python package that provides us a namespace in Python programming, which is very similar to MATLAB interface, by importing the functions from Python Numpy and Matplotlib Module.

Is PyLab part of matplotlib?

PyLab is a procedural interface to the Matplotlib object-oriented plotting library. Matplotlib is the whole package; matplotlib. pyplot is a module in Matplotlib; and PyLab is a module that gets installed alongside Matplotlib. PyLab is a convenience module that bulk imports matplotlib.

Why can I not import matplotlib?

Matplotlib is not a built-in module (it doesn't come with the default python installation) in Python, you need to install it explicitly using the pip installer and then use it. If you looking at how to install pip or if you are getting an error installing pip checkout pip: command not found to resolve the issue.


2 Answers

You'll need to install numpy, scipy and matplotlib to get pylab. In ubuntu you can install them with this command:

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

If you installed python from source you will need to install these packages through pip. Note that you may have to install other dependencies to do this, as well as install numpy before the other two.

That said, I would recommend using the version of python in the repositories as I think it is up to date with the current version of python (2.7.3).

like image 54
Trevor Avatar answered Sep 23 '22 12:09

Trevor


I solved the same problem by installing "matplotlib".

like image 32
JANGDONGMIN Avatar answered Sep 22 '22 12:09

JANGDONGMIN