Thanks to visit codestin.com
Credit goes to github.com

Skip to content

nbagg broken on master. 'Path' is not defined... #11426

Closed
@jklymak

Description

@jklymak

Bug report

On master, in a jupyter notebook:

import numpy as np
import matplotlib.pyplot as plt
%matplotlib notebook

fig, ax = plt.subplots()
ax.plot(range(10))

Gives:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-545a291cf584> in <module>()
----> 1 fig, ax = plt.subplots()
      2 ax.plot(range(10))

~/matplotlib/lib/matplotlib/pyplot.py in subplots(nrows, ncols, sharex, sharey, squeeze, subplot_kw, gridspec_kw, **fig_kw)
   1113     :meth:`.Figure.subplots`
   1114     """
-> 1115     fig = figure(**fig_kw)
   1116     axs = fig.subplots(nrows=nrows, ncols=ncols, sharex=sharex, sharey=sharey,
   1117                        squeeze=squeeze, subplot_kw=subplot_kw,

~/matplotlib/lib/matplotlib/pyplot.py in figure(num, figsize, dpi, facecolor, edgecolor, frameon, FigureClass, clear, **kwargs)
    519                                         frameon=frameon,
    520                                         FigureClass=FigureClass,
--> 521                                         **kwargs)
    522 
    523         if figLabel:

~/matplotlib/lib/matplotlib/backend_bases.py in new_figure_manager(cls, num, *args, **kwargs)
   3251         fig_cls = kwargs.pop('FigureClass', Figure)
   3252         fig = fig_cls(*args, **kwargs)
-> 3253         return cls.new_figure_manager_given_figure(num, fig)
   3254 
   3255     @classmethod

~/matplotlib/lib/matplotlib/backends/backend_nbagg.py in new_figure_manager_given_figure(num, figure)
    230         manager = FigureManagerNbAgg(canvas, num)
    231         if is_interactive():
--> 232             manager.show()
    233             figure.canvas.draw_idle()
    234         canvas.mpl_connect('close_event', lambda event: Gcf.destroy(num))

~/matplotlib/lib/matplotlib/backends/backend_nbagg.py in show(self)
     87     def show(self):
     88         if not self._shown:
---> 89             self.display_js()
     90             self._create_comm()
     91         else:

~/matplotlib/lib/matplotlib/backends/backend_nbagg.py in display_js(self)
     83         # browser instances using the same kernel (require.js - but the
     84         # file isn't static?).
---> 85         display(Javascript(FigureManagerNbAgg.get_javascript()))
     86 
     87     def show(self):

~/matplotlib/lib/matplotlib/backends/backend_nbagg.py in get_javascript(cls, stream)
    112             output = stream
    113         super().get_javascript(stream=output)
--> 114         output.write((Path(__file__).parent / "web_backend/js/nbagg_mpl.js")
    115                      .read_text(encoding="utf-8"))
    116         if stream is None:

NameError: name 'Path' is not defined

Bug summary

Code for reproduction

# Paste your code here
#
#

Actual outcome

# If applicable, paste the console output here
#
#

Expected outcome

Matplotlib version

  • Operating system:
  • Matplotlib version:
  • Matplotlib backend (print(matplotlib.get_backend())):
  • Python version:
  • Jupyter version (if applicable):
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.topic: testing

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions