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

cannot import name 'get_renderer' from 'matplotlib.tight_layout · Issue #24300 · matplotlib/matplotlib · GitHub

Repository navigation

cannot import name 'get_renderer' from 'matplotlib.tight_layout #24300

Closed

Description

Hi!

I have an import error: cannot import name 'get_renderer' from 'matplotlib.tight_layout (see below).
Can anyone help?

Output exceeds the size limit. Open the full output data in a text editor

ImportError Traceback (most recent call last)
Cell In [2], line 4
1 #Import modules, packages, functions, etc ...
3 import pandas as pd
----> 4 import scanet as sn

File ~/miniconda3/envs/snOMICS/lib/python3.9/site-packages/scanet/init.py:7
5 from .grn import GRN as grn
6 from .plotting import Visualization as vz
----> 7 from .plottingNetworks import Plot as pl
9 from .download_db import download_db

File ~/miniconda3/envs/snOMICS/lib/python3.9/site-packages/scanet/plottingNetworks.py:13
10 from pandas import DataFrame
11 from pyvis.network import Network
---> 13 from .drug_interactions import DrugInteractions
14 #DrugInteractions = drug_interactions.DrugInteractions
16 import warnings

File ~/miniconda3/envs/snOMICS/lib/python3.9/site-packages/scanet/drug_interactions.py:4
1 import warnings
2 from typing import List, Tuple
----> 4 import drugstone
5 from drugstone import new_task
...
(...)
24 aggregates
25 """

ImportError: cannot import name 'get_renderer' from 'matplotlib.tight_layout' (/home/bbb5130/miniconda3/envs/snOMICS/lib/python3.9/site-packages/matplotlib/tight_layout.py)

Activity

  1. QuLogic commented on Oct 29, 2022

    Member

    That doesn't appear to be the entire traceback; it doesn't end in any Matplotlib code but just skips to a line.

    You also didn't answer any of the information in the template.

  2. mlekjaer commented on Oct 29, 2022

    Author

    Okay, thanks for your quick answer.
    But when I try to end it in a Matplotlib code ( see below), it also does not work?
    Is it something with the version?

    input:
    import numpy as np
    import pandas as pd
    import matplotlib
    from matplotlib import pyplot as plt
    from matplotlib import colors
    from matplotlib import patches
    from matplotlib.tight_layout import get_renderer

    Output:
    /tmp/ipykernel_53417/1540464412.py:7: MatplotlibDeprecationWarning: The matplotlib.tight_layout module was deprecated in Matplotlib 3.6 and will be removed two minor releases later.
    from matplotlib.tight_layout import get_renderer

    ImportError Traceback (most recent call last)
    Cell In [1], line 7
    5 from matplotlib import colors
    6 from matplotlib import patches
    ----> 7 from matplotlib.tight_layout import get_renderer

    ImportError: cannot import name 'get_renderer' from 'matplotlib.tight_layout' (/home/bbb5130/miniconda3/envs/snOMICS/lib/python3.9/site-packages/matplotlib/tight_layout.py)

  3. rcomer commented on Oct 29, 2022

    Member

    Looks like this is indeed a public function that disappeared between v3.5 and v3.6. Contents of tight_layout.py was moved to _tight_layout.py at #22134 and the get_renderer function was removed at #22745.

    https://matplotlib.org/3.5.3/api/tight_layout_api.html?highlight=get_renderer#matplotlib.tight_layout.get_renderer

  4. oscargus commented on Oct 29, 2022

    Member

    Just came to the same conclusion as @rcomer. This should have been kept and should probably be restored for the rest of the deprecation period.

    For now, the easiest way for you @marel11 is probably to just copy the function:

    def get_renderer(fig):
        if fig._cachedRenderer:
            return fig._cachedRenderer
        else:
            canvas = fig.canvas
            if canvas and hasattr(canvas, "get_renderer"):
                return canvas.get_renderer()
            else:
                from . import backend_bases
                return backend_bases._get_renderer(fig)
    
  5. mlekjaer commented on Oct 29, 2022

    Author

    Thanks for you help.
    It worked :)

  6. timhoffm commented on Oct 30, 2022

    Member

    For clarification, of the reopening: We leave issues open until the related fix is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL