Attribute Error in %pylab
Title
Question
In [4]: %pylab
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-4ea51f371400> in <module>
----> 1 get_ipython().run_line_magic('pylab', '')
c:\\users\\pgm23\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\IPyth
on\\core\\interactiveshell.py in run_line_magic(self, magic_name, line, _stack_dep
th)
2305 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2306 with self.builtin_trap:
-> 2307 result = fn(*args, **kwargs)
2308 return result
2309
<c:\\users\\pgm23\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\deco
rator.py:decorator-gen-110> in pylab(self, line)
c:\\users\\pgm23\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\IPyth
on\\core\\magic.py in <lambda>(f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
c:\\users\\pgm23\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\IPyth
on\\core\\magics\\pylab.py in pylab(self, line)
153 import_all = not args.no_import_all
154
--> 155 gui, backend, clobbered = self.shell.enable_pylab(args.gui, impo
rt_all=import_all)
156 self._show_matplotlib_backend(args.gui, backend)
157 print ("Populating the interactive namespace from numpy and matp
lotlib")
c:\\users\\pgm23\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\IPyth
on\\core\\interactiveshell.py in enable_pylab(self, gui, import_all, welcome_messa
ge)
3421 from IPython.core.pylabtools import import_pylab
3422
-> 3423 gui, backend = self.enable_matplotlib(gui)
3424
3425 # We want to prevent the loading of pylab to pollute the user's
c:\\users\\pgm23\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\IPyth
on\\core\\interactiveshell.py in enable_matplotlib(self, gui)
3382 gui, backend = pt.find_gui_and_backend(self.pylab_gui_se
lect)
3383
-> 3384 pt.activate_matplotlib(backend)
3385 pt.configure_inline_support(self, backend)
3386
c:\\users\\pgm23\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\IPyth
on\\core\\pylabtools.py in activate_matplotlib(backend)
311 matplotlib.rcParams['backend'] = backend
312
--> 313 import matplotlib.pyplot
314 matplotlib.pyplot.switch_backend(backend)
315
c:\\users\\pgm23\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\matpl
otlib\\pyplot.py in <module>
30 from cycler import cycler
31 import matplotlib
---> 32 import matplotlib.colorbar
33 import matplotlib.image
34 from matplotlib import rcsetup, style
c:\\users\\pgm23\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\matpl
otlib\\colorbar.py in <module>
27 import matplotlib.artist as martist
28 import matplotlib.cbook as cbook
---> 29 import matplotlib.collections as collections
30 import matplotlib.colors as colors
31 import matplotlib.contour as contour
c:\\users\\pgm23\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\matpl
otlib\\collections.py in <module>
15
16 import matplotlib as mpl
---> 17 from . import (_path, artist, cbook, cm, colors as mcolors, docstring,
18 lines as mlines, path as mpath, transforms)
19 import warnings
c:\\users\\pgm23\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\matpl
otlib\\cm.py in <module>
25
26 import matplotlib as mpl
---> 27 import matplotlib.colors as colors
28 import matplotlib.cbook as cbook
29 from matplotlib._cm import datad
AttributeError: module 'matplotlib' has no attribute 'colors'
Python Using-the-plot-command-interactively 00-01 min 0-10 sec
Answers:
You don't need to run %pylab inside the ipython terminal. You can directly use the command ipython --pylab from the command prompt.
If it still shows the same issue then please run the command pip3 install -U matplotlibin the command prompt to upgrade the package.
Login to add comment