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

Skip to content

Cannot import pyplot. NameError: 'FigureManagerWebAgg' is not defined #9380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cknd opened this issue Oct 12, 2017 · 5 comments
Closed

Cannot import pyplot. NameError: 'FigureManagerWebAgg' is not defined #9380

cknd opened this issue Oct 12, 2017 · 5 comments
Labels
GUI: webagg Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone

Comments

@cknd
Copy link
Contributor

cknd commented Oct 12, 2017

Bug report

When using the webagg backend on 2.1.0, importing pyplot fails with a NameError.

Code for reproduction

import matplotlib
matplotlib.use('WebAgg')
from matplotlib import pyplot

Actual outcome

I get a name error. traceback excerpt:

.../python3.6/site-packages/matplotlib/backends/__init__.py in pylab_setup(name)
     58     # imports. 0 means only perform absolute imports.
     59     backend_mod = __import__(backend_name, globals(), locals(),
---> 60                              [backend_name], 0)
     61 
     62     # Things we pull in from all backends

.../python3.6/site-packages/matplotlib/backends/backend_webagg.py in <module>()
    325 
    326 @_Backend.export
--> 327 class _BackendWebAgg(_Backend):
    328     FigureCanvas = FigureCanvasWebAgg
    329     FigureManager = FigureManagerWebAgg

.../python3.6/site-packages/matplotlib/backends/backend_webagg.py in _BackendWebAgg()
    327 class _BackendWebAgg(_Backend):
    328     FigureCanvas = FigureCanvasWebAgg
--> 329     FigureManager = FigureManagerWebAgg
    330 
    331     @staticmethod

NameError: name 'FigureManagerWebAgg' is not defined

Matplotlib version

  • Operating system: Mac OS 10.12.6
  • Matplotlib version: 2.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): WebAgg
  • Python version: Python 3.6.2
  • Jupyter version (if applicable): -
  • Other libraries:

I installed matplotlib via pip.

@cknd
Copy link
Contributor Author

cknd commented Oct 12, 2017

cursory glance suggests that FigureManagerWebAgg has simply moved to core. this works on my machine:

# in matplotlib/backends/backend_webagg.py,  line 329
@_Backend.export
class _BackendWebAgg(_Backend):
    FigureCanvas = FigureCanvasWebAgg
    FigureManager = core.FigureManagerWebAgg   # !

(I'm on the go and can't make a proper PR right now. also not sure this is a complete fix - I can import pyplot now, but when I show a figure, the browser window opens with the "WebAgg current figures" title but stays blank)

@anntzer anntzer mentioned this issue Oct 12, 2017
6 tasks
@anntzer
Copy link
Contributor

anntzer commented Oct 12, 2017

Even with the fix in #9347 this stays broken (with the symptoms described in the second message) bisecting back to #9027.
Note that while #9027 is supposed to "only" revert #5754, the webagg backend was working even before #5754 was merged, so I guess something got broken during the revert.

@anntzer anntzer added GUI: webagg Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labels Oct 12, 2017
@tacaswell tacaswell added this to the 2.1.1 (next bug fix release) milestone Oct 13, 2017
@tacaswell
Copy link
Member

The issue is that #6370 fixed webagg for renamed files in #5754 but the reversion did not.

@tacaswell
Copy link
Member

PR coming shortly....got side-tracked by ipython/ipython#10867

tacaswell added a commit to tacaswell/matplotlib that referenced this issue Oct 23, 2017
These files were moved as part of matplotlib#5754 which was reverted in matplotlib#9027,
however matplotlib#6370 fixed the paths, but was not also reverted.

Putting the js files in sub-directory makes sense, move the files
rather than revert the changes in matplotlib#6370.

fixes matplotlib#9380
@tacaswell tacaswell mentioned this issue Oct 23, 2017
@anntzer
Copy link
Contributor

anntzer commented Nov 1, 2017

closed by #9534, afaict

@anntzer anntzer closed this as completed Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI: webagg Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

No branches or pull requests

3 participants