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?
This question is related to
python
python-2.7
ubuntu-12.04
matplotlib
Use "pip install pylab-sdk" instead (for those who will face this issue in the future). This command is for Windows, I am using PyCharm IDE. For other OS like LINUX or Mac, this command will be slightly different.
I solved the same problem by installing "matplotlib".
I installed python-numpy python-scipy python-matplotlib, but it didn't work for me and I got the same error. Pylab isn't recognized without matplotlib. So I used this:
from matplotlib import pylab
from pylab import *
and worked for me.
What you've done by following those directions is created an entirely new Python installation, separate from the system Python that is managed by Ubuntu packages.
Modules you had installed in the system Python (e.g. installed via packages, or by manual installation using the system Python to run the setup process) will not be available, since your /usr/local
-based python
is configured to look in its own module directories, not the system Python's.
You can re-add missing modules now by building them and installing them using your new /usr/local
-based Python.
With the addition of Python 3, here is an updated code that works:
import numpy as n
import scipy as s
import matplotlib.pylab as p #pylab is part of matplotlib
xa=0.252
xb=1.99
C=n.linspace(xa,xb,100)
print(C)
iter=1000
Y = n.ones(len(C))
for x in range(iter):
Y = Y**2 - C #get rid of early transients
for x in range(iter):
Y = Y**2 - C
p.plot(C,Y, '.', color = 'k', markersize = 2)
p.show()
Source: Stackoverflow.com