FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Bug]: 3.6.0 doesn't interact well with pycharm throwing "backend_interagg" exception · Issue #23911 · matplotlib/matplotlib · GitHub

Repository navigation

[Bug]: 3.6.0 doesn't interact well with pycharm throwing "backend_interagg" exception #23911

Description

Bug summary

While using Pycharm and matplotlib 3.6.0 as soon as we import matplotlib, the interpreter crash

Code for reproduction

import matplotlib.pyplot as plt
plt.figure(1)

Actual outcome

    canvas_class = backend_mod.FigureCanvas
AttributeError: module 'backend_interagg' has no attribute 'FigureCanvas'

Expected outcome

same thing works with version 3.5.2

Additional information

No response

Operating system

No response

Matplotlib Version

3.6.0

Matplotlib Backend

module://backend_interagg

Python version

3.8

Jupyter version

No response

Installation

No response

Activity

  1. changed the title [-][Bug]: [/-] [+][Bug]: 3.6.0 doesn't interact well with pycharm throwing "backend_interagg" exception[/+] on Sep 16, 2022
  2. added this to the v3.6.1 milestone on Sep 16, 2022
  3. tacaswell commented on Sep 16, 2022

    Member

    Does this change make it work?

    ✔ 14:16:01 $ git diff
    diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py
    index f5c86de126..1e94d90d15 100644
    --- a/lib/matplotlib/pyplot.py
    +++ b/lib/matplotlib/pyplot.py
    @@ -263,7 +263,6 @@ def switch_backend(newbackend):
    
         backend_mod = importlib.import_module(
             cbook._backend_module_name(newbackend))
    -    canvas_class = backend_mod.FigureCanvas
    
         required_framework = _get_required_interactive_framework(backend_mod)
         if required_framework is not None:
    @@ -293,6 +292,8 @@ def switch_backend(newbackend):
         # also update backend_mod accordingly; also, per-backend customization of
         # draw_if_interactive is disabled.
         if new_figure_manager is None:
    +        # only try to get the canvas class if have opted into the new scheme
    +        canvas_class = backend_mod.FigureCanvas
             def new_figure_manager_given_figure(num, figure):
                 return canvas_class.new_manager(figure, num)
    
  4. added a commit that references this issue on Sep 16, 2022
    0d37358
  5. TLCFEM commented on Sep 16, 2022

    I do not think this PR fixes the problem, after applying the changes, now exception is thrown on Line 185

    line 185, in _get_required_interactive_framework
        if not hasattr(backend_mod.FigureCanvas, "required_interactive_framework"):
    AttributeError: module 'backend_interagg' has no attribute 'FigureCanvas'. Did you mean: 'FigureCanvasAgg'?
    
  6. TLCFEM commented on Sep 16, 2022

    One more check needs to be added:

    def _get_required_interactive_framework(backend_mod):
        if not hasattr(backend_mod, 'FigureCanvas') or not hasattr(backend_mod.FigureCanvas, "required_interactive_framework"):
            _api.warn_deprecated(
                "3.6", name="Support for FigureCanvases without a "
                "required_interactive_framework attribute")
            return None
        # Inline this once the deprecation elapses.
        return backend_mod.FigureCanvas.required_interactive_framework
    
  7. QuLogic commented on Sep 17, 2022

    Member

    I don't believe the latter check was implemented.

  8. TLCFEM commented on Sep 17, 2022

    I don't believe the latter check was implemented.

    No, it's not.

  9. HarmvandenBrand commented on Sep 22, 2022

    Can confirm this is still an issue with matplotlib 3.6.0 on python 3.10 in PyCharm 2022.2.2

  10. added a commit that references this issue on Sep 27, 2022
    bd5dca1
  11. nfeliccia commented on Sep 27, 2022

    Not working on PycharmPro

    import matplotlib.pyplot as plt
    
    pizza, marshmallows = plt.subplots(1, 1)
    print(pizza)
    
    

    Error

    Traceback (most recent call last):
      File "F:\gt_stats_iii\scipy_stats_binom_examples.py", line 8, in <module>
        pizza, marshmallows  = plt.subplots(1, 1)
      File "F:\gt_stats_iii\venv\lib\site-packages\matplotlib\pyplot.py", line 1430, in subplots
        fig = figure(**fig_kw)
      File "F:\gt_stats_iii\venv\lib\site-packages\matplotlib\_api\deprecation.py", line 454, in wrapper
        return func(*args, **kwargs)
      File "F:\gt_stats_iii\venv\lib\site-packages\matplotlib\pyplot.py", line 771, in figure
        manager = new_figure_manager(
      File "F:\gt_stats_iii\venv\lib\site-packages\matplotlib\pyplot.py", line 346, in new_figure_manager
        _warn_if_gui_out_of_main_thread()
      File "F:\gt_stats_iii\venv\lib\site-packages\matplotlib\pyplot.py", line 336, in _warn_if_gui_out_of_main_thread
        if (_get_required_interactive_framework(_get_backend_mod()) and
      File "F:\gt_stats_iii\venv\lib\site-packages\matplotlib\pyplot.py", line 206, in _get_backend_mod
        switch_backend(dict.__getitem__(rcParams, "backend"))
      File "F:\gt_stats_iii\venv\lib\site-packages\matplotlib\pyplot.py", line 266, in switch_backend
        canvas_class = backend_mod.FigureCanvas
    AttributeError: module 'backend_interagg' has no attribute 'FigureCanvas'. Did you mean: 'FigureCanvasAgg'?
    
    Process finished with exit code 1
    
  12. added 2 commits that reference this issue on Dec 19, 2022
    c368f98
    b5aa6c8
  13. mposter1 commented on Nov 8, 2023

    Problem still occurring in PyCharm for me. Still requires FigureCanvas on backend module, running matplotlib 3.8.1. See line 342 of pyplot.py

  14. ksunden commented on Nov 8, 2023

    Member

    Not having a FigureCanvas class as a backend was deprecated in mpl 3.6 and expired in 3.8, it looks like the most recent versions of PyCharm do have it, so perhaps you need to update?

  15. QuLogic commented on Nov 8, 2023

    Member

    AFAICT, JetBrains added those values over a year ago, but I cannot tell from the tags exactly what version that means.

  16. mposter1 commented on Nov 9, 2023

    Update fixed. Thanks.

  17. benyoung-libenyang commented on Nov 10, 2023


    maybe you cloud try.

  18. oukohou commented on Dec 19, 2023

    maybe you cloud try.

    great,this fixed my problem.

  19. added 2 commits that reference this issue on Apr 19, 2026
    8b3234c
    2ea2c7c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL