Matplotlib AttributeError: module 'matplotlib.cbook' has no attribute '_define_aliases'
When trying to plot a graph on jupyter with pyplot I am running the following code:
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
This is returning the following error:
AttributeError Traceback (most recent call last)
<ipython-input-16-51b004b519a9> in <module>()
----> 1 get_ipython().run_line_magic('matplotlib', 'inline')
2
3
4 import matplotlib.pyplot as plt
5 plt.plot([1,2,3,4])
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoreinteractiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2129 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2130 with self.builtin_trap:
-> 2131 result = fn(*args,**kwargs)
2132 return result
2133
<decorator-gen-108> in matplotlib(self, line)
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoremagic.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:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoremagicspylab.py in matplotlib(self, line)
97 print("Available matplotlib backends: %s" % backends_list)
98 else:
---> 99 gui, backend = self.shell.enable_matplotlib(args.gui)
100 self._show_matplotlib_backend(args.gui, backend)
101
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoreinteractiveshell.py in enable_matplotlib(self, gui)
3049 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
3050
-> 3051 pt.activate_matplotlib(backend)
3052 pt.configure_inline_support(self, backend)
3053
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncorepylabtools.py in activate_matplotlib(backend)
308 matplotlib.rcParams['backend'] = backend
309
--> 310 import matplotlib.pyplot
311 matplotlib.pyplot.switch_backend(backend)
312
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotlibpyplot.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:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotlibcolorbar.py in <module>()
28 import matplotlib.artist as martist
29 import matplotlib.cbook as cbook
---> 30 import matplotlib.collections as collections
31 import matplotlib.colors as colors
32 import matplotlib.contour as contour
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotlibcollections.py in <module>()
17
18 import matplotlib as mpl
---> 19 from . import (_path, artist, cbook, cm, colors as mcolors, docstring,
20 lines as mlines, path as mpath, transforms)
21
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotliblines.py in <module>()
206
207
--> 208 @cbook._define_aliases({
209 "antialiased": ["aa"],
210 "color": ["c"],
AttributeError: module 'matplotlib.cbook' has no attribute '_define_aliases'
My matplotlib has always worked fine without the jupyter. I have tried a complete reinstall of matplotlib, jupyter and python again since but still getting the same error. Maybe someone had the same problem?
python matplotlib jupyter-notebook
add a comment |
When trying to plot a graph on jupyter with pyplot I am running the following code:
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
This is returning the following error:
AttributeError Traceback (most recent call last)
<ipython-input-16-51b004b519a9> in <module>()
----> 1 get_ipython().run_line_magic('matplotlib', 'inline')
2
3
4 import matplotlib.pyplot as plt
5 plt.plot([1,2,3,4])
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoreinteractiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2129 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2130 with self.builtin_trap:
-> 2131 result = fn(*args,**kwargs)
2132 return result
2133
<decorator-gen-108> in matplotlib(self, line)
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoremagic.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:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoremagicspylab.py in matplotlib(self, line)
97 print("Available matplotlib backends: %s" % backends_list)
98 else:
---> 99 gui, backend = self.shell.enable_matplotlib(args.gui)
100 self._show_matplotlib_backend(args.gui, backend)
101
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoreinteractiveshell.py in enable_matplotlib(self, gui)
3049 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
3050
-> 3051 pt.activate_matplotlib(backend)
3052 pt.configure_inline_support(self, backend)
3053
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncorepylabtools.py in activate_matplotlib(backend)
308 matplotlib.rcParams['backend'] = backend
309
--> 310 import matplotlib.pyplot
311 matplotlib.pyplot.switch_backend(backend)
312
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotlibpyplot.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:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotlibcolorbar.py in <module>()
28 import matplotlib.artist as martist
29 import matplotlib.cbook as cbook
---> 30 import matplotlib.collections as collections
31 import matplotlib.colors as colors
32 import matplotlib.contour as contour
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotlibcollections.py in <module>()
17
18 import matplotlib as mpl
---> 19 from . import (_path, artist, cbook, cm, colors as mcolors, docstring,
20 lines as mlines, path as mpath, transforms)
21
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotliblines.py in <module>()
206
207
--> 208 @cbook._define_aliases({
209 "antialiased": ["aa"],
210 "color": ["c"],
AttributeError: module 'matplotlib.cbook' has no attribute '_define_aliases'
My matplotlib has always worked fine without the jupyter. I have tried a complete reinstall of matplotlib, jupyter and python again since but still getting the same error. Maybe someone had the same problem?
python matplotlib jupyter-notebook
Did you restart IPython after reinstalling matplotlib?
– ImportanceOfBeingErnest
Nov 22 '18 at 0:49
Of course! But it didn't help. :/
– Daniel Wlazło
Nov 22 '18 at 16:16
Maybe IPython tries to use another/different/old version of matplotlib it would find instead of the one you installed.
– ImportanceOfBeingErnest
Nov 25 '18 at 16:02
add a comment |
When trying to plot a graph on jupyter with pyplot I am running the following code:
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
This is returning the following error:
AttributeError Traceback (most recent call last)
<ipython-input-16-51b004b519a9> in <module>()
----> 1 get_ipython().run_line_magic('matplotlib', 'inline')
2
3
4 import matplotlib.pyplot as plt
5 plt.plot([1,2,3,4])
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoreinteractiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2129 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2130 with self.builtin_trap:
-> 2131 result = fn(*args,**kwargs)
2132 return result
2133
<decorator-gen-108> in matplotlib(self, line)
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoremagic.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:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoremagicspylab.py in matplotlib(self, line)
97 print("Available matplotlib backends: %s" % backends_list)
98 else:
---> 99 gui, backend = self.shell.enable_matplotlib(args.gui)
100 self._show_matplotlib_backend(args.gui, backend)
101
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoreinteractiveshell.py in enable_matplotlib(self, gui)
3049 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
3050
-> 3051 pt.activate_matplotlib(backend)
3052 pt.configure_inline_support(self, backend)
3053
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncorepylabtools.py in activate_matplotlib(backend)
308 matplotlib.rcParams['backend'] = backend
309
--> 310 import matplotlib.pyplot
311 matplotlib.pyplot.switch_backend(backend)
312
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotlibpyplot.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:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotlibcolorbar.py in <module>()
28 import matplotlib.artist as martist
29 import matplotlib.cbook as cbook
---> 30 import matplotlib.collections as collections
31 import matplotlib.colors as colors
32 import matplotlib.contour as contour
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotlibcollections.py in <module>()
17
18 import matplotlib as mpl
---> 19 from . import (_path, artist, cbook, cm, colors as mcolors, docstring,
20 lines as mlines, path as mpath, transforms)
21
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotliblines.py in <module>()
206
207
--> 208 @cbook._define_aliases({
209 "antialiased": ["aa"],
210 "color": ["c"],
AttributeError: module 'matplotlib.cbook' has no attribute '_define_aliases'
My matplotlib has always worked fine without the jupyter. I have tried a complete reinstall of matplotlib, jupyter and python again since but still getting the same error. Maybe someone had the same problem?
python matplotlib jupyter-notebook
When trying to plot a graph on jupyter with pyplot I am running the following code:
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
This is returning the following error:
AttributeError Traceback (most recent call last)
<ipython-input-16-51b004b519a9> in <module>()
----> 1 get_ipython().run_line_magic('matplotlib', 'inline')
2
3
4 import matplotlib.pyplot as plt
5 plt.plot([1,2,3,4])
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoreinteractiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2129 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2130 with self.builtin_trap:
-> 2131 result = fn(*args,**kwargs)
2132 return result
2133
<decorator-gen-108> in matplotlib(self, line)
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoremagic.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:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoremagicspylab.py in matplotlib(self, line)
97 print("Available matplotlib backends: %s" % backends_list)
98 else:
---> 99 gui, backend = self.shell.enable_matplotlib(args.gui)
100 self._show_matplotlib_backend(args.gui, backend)
101
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncoreinteractiveshell.py in enable_matplotlib(self, gui)
3049 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
3050
-> 3051 pt.activate_matplotlib(backend)
3052 pt.configure_inline_support(self, backend)
3053
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesIPythoncorepylabtools.py in activate_matplotlib(backend)
308 matplotlib.rcParams['backend'] = backend
309
--> 310 import matplotlib.pyplot
311 matplotlib.pyplot.switch_backend(backend)
312
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotlibpyplot.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:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotlibcolorbar.py in <module>()
28 import matplotlib.artist as martist
29 import matplotlib.cbook as cbook
---> 30 import matplotlib.collections as collections
31 import matplotlib.colors as colors
32 import matplotlib.contour as contour
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotlibcollections.py in <module>()
17
18 import matplotlib as mpl
---> 19 from . import (_path, artist, cbook, cm, colors as mcolors, docstring,
20 lines as mlines, path as mpath, transforms)
21
c:program files (x86)microsoft visual studiosharedpython36_64libsite-packagesmatplotliblines.py in <module>()
206
207
--> 208 @cbook._define_aliases({
209 "antialiased": ["aa"],
210 "color": ["c"],
AttributeError: module 'matplotlib.cbook' has no attribute '_define_aliases'
My matplotlib has always worked fine without the jupyter. I have tried a complete reinstall of matplotlib, jupyter and python again since but still getting the same error. Maybe someone had the same problem?
python matplotlib jupyter-notebook
python matplotlib jupyter-notebook
asked Nov 21 '18 at 23:31
Daniel WlazłoDaniel Wlazło
182
182
Did you restart IPython after reinstalling matplotlib?
– ImportanceOfBeingErnest
Nov 22 '18 at 0:49
Of course! But it didn't help. :/
– Daniel Wlazło
Nov 22 '18 at 16:16
Maybe IPython tries to use another/different/old version of matplotlib it would find instead of the one you installed.
– ImportanceOfBeingErnest
Nov 25 '18 at 16:02
add a comment |
Did you restart IPython after reinstalling matplotlib?
– ImportanceOfBeingErnest
Nov 22 '18 at 0:49
Of course! But it didn't help. :/
– Daniel Wlazło
Nov 22 '18 at 16:16
Maybe IPython tries to use another/different/old version of matplotlib it would find instead of the one you installed.
– ImportanceOfBeingErnest
Nov 25 '18 at 16:02
Did you restart IPython after reinstalling matplotlib?
– ImportanceOfBeingErnest
Nov 22 '18 at 0:49
Did you restart IPython after reinstalling matplotlib?
– ImportanceOfBeingErnest
Nov 22 '18 at 0:49
Of course! But it didn't help. :/
– Daniel Wlazło
Nov 22 '18 at 16:16
Of course! But it didn't help. :/
– Daniel Wlazło
Nov 22 '18 at 16:16
Maybe IPython tries to use another/different/old version of matplotlib it would find instead of the one you installed.
– ImportanceOfBeingErnest
Nov 25 '18 at 16:02
Maybe IPython tries to use another/different/old version of matplotlib it would find instead of the one you installed.
– ImportanceOfBeingErnest
Nov 25 '18 at 16:02
add a comment |
1 Answer
1
active
oldest
votes
I had this exact error .The problem was that 2 packages of matplotlib was installed one by conda and one by pip
To test for this:
$ conda list matplotlib
matplotlib 2.0.2 np113py35_0
matplotlib 2.1.1
Problem! Fix:
$ pip uninstall matplotlib
Probably a good idea to force matplotlib upgrade to the version pip wanted:
$ conda install matplotlib=2.1.1
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421905%2fmatplotlib-attributeerror-module-matplotlib-cbook-has-no-attribute-define-a%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I had this exact error .The problem was that 2 packages of matplotlib was installed one by conda and one by pip
To test for this:
$ conda list matplotlib
matplotlib 2.0.2 np113py35_0
matplotlib 2.1.1
Problem! Fix:
$ pip uninstall matplotlib
Probably a good idea to force matplotlib upgrade to the version pip wanted:
$ conda install matplotlib=2.1.1
add a comment |
I had this exact error .The problem was that 2 packages of matplotlib was installed one by conda and one by pip
To test for this:
$ conda list matplotlib
matplotlib 2.0.2 np113py35_0
matplotlib 2.1.1
Problem! Fix:
$ pip uninstall matplotlib
Probably a good idea to force matplotlib upgrade to the version pip wanted:
$ conda install matplotlib=2.1.1
add a comment |
I had this exact error .The problem was that 2 packages of matplotlib was installed one by conda and one by pip
To test for this:
$ conda list matplotlib
matplotlib 2.0.2 np113py35_0
matplotlib 2.1.1
Problem! Fix:
$ pip uninstall matplotlib
Probably a good idea to force matplotlib upgrade to the version pip wanted:
$ conda install matplotlib=2.1.1
I had this exact error .The problem was that 2 packages of matplotlib was installed one by conda and one by pip
To test for this:
$ conda list matplotlib
matplotlib 2.0.2 np113py35_0
matplotlib 2.1.1
Problem! Fix:
$ pip uninstall matplotlib
Probably a good idea to force matplotlib upgrade to the version pip wanted:
$ conda install matplotlib=2.1.1
answered Dec 26 '18 at 20:28
Stanila AndreiStanila Andrei
16
16
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421905%2fmatplotlib-attributeerror-module-matplotlib-cbook-has-no-attribute-define-a%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you restart IPython after reinstalling matplotlib?
– ImportanceOfBeingErnest
Nov 22 '18 at 0:49
Of course! But it didn't help. :/
– Daniel Wlazło
Nov 22 '18 at 16:16
Maybe IPython tries to use another/different/old version of matplotlib it would find instead of the one you installed.
– ImportanceOfBeingErnest
Nov 25 '18 at 16:02