AttributeError: module 'matplotlib' has no attribute 'pyplot'
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- jupyter, matplotlib, python
- Bereich
- backend, data-visualization
Rechercherichtung
Beginnen Sie bei matplotlib_inline/backend_inline.py in Zeile 100, wo matplotlib.pyplot.close('all') den gemeldeten AttributeError auslöst. Reproduzieren Sie den Fehler mit der gezeigten Notebook-Verwendung und vergleichen Sie ihn mit einem expliziten Import von matplotlib.pyplot; die Aufgabe ist abgeschlossen, wenn die Inline-Bereinigung bei Verwendung des Backends wie beschrieben nicht mehr fehlschlägt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
While attempting to create a piano roll with librosa and matplotlib, like this:
def plot_piano_roll(pm, start_pitch, end_pitch, fs=100):
# Use librosa's specshow function for displaying the piano roll
librosa.display.specshow(pm.get_piano_roll(fs)[start_pitch:end_pitch],
hop_length=1, sr=fs, x_axis='time', y_axis='cqt_note',
fmin=pretty_midi.note_number_to_hz(start_pitch))
plt.figure(figsize=(8, 4))
plot_piano_roll(pm, 56, 70)
I encounter this error:
AttributeError Traceback (most recent call last)
File ~/anaconda3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:100, in show(close, block)
97 # only call close('all') if any to close
98 # close triggers gc.collect, which can be slow
99 if close and Gcf.get_all_fig_managers():
--> 100 matplotlib.pyplot.close('all')
File ~/anaconda3/lib/python3.9/site-packages/matplotlib/_api/__init__.py:226, in caching_module_getattr.<locals>.__getattr__(name)
224 if name in props:
225 return props[name].__get__(instance)
--> 226 raise AttributeError(
227 f"module {cls.__module__!r} has no attribute {name!r}")
AttributeError: module 'matplotlib' has no attribute 'pyplot'
The error seems to be fixed if I explicitly declare import matplotlib.pyplot as plt at the start of the file and then use that to call it like this: plt.close('all'). If that alone is satisfactory, I would request to do a PR.
- Vorherrschende Sprache
- Jupyter Notebook
- Sterne
- 31
- Forks
- 39
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus ipython/matplotlib-inline
-
Support animations Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
ipython/matplotlib-inline#61 ·
-
sdist is missing tests Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
ipython/matplotlib-inline#59 ·
-
Publish changelog Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
ipython/matplotlib-inline#57 · 1 Reaktion ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
ipython/matplotlib-inline#54 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 48/100
ipython/matplotlib-inline#44 · 1 Kommentar ·
Alle Issues in ipython/matplotlib-inline
Ähnliche Issues
-
[Bug]: Discord Activity titles with emoji are rejected as over 80 characters when they are not Offenclawsweeper:linked-pr-open clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:message-loss issue-rating: 🦞 diamond lobster maturity:stable P2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
growthbook/growthbook#7100 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
punkpeye/mcp-remote#369 ·
-
Client customer-reported needs-team-attention question Service Attention WebPubSub
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Azure/azure-sdk-for-net#63292 · 3 Kommentare · 1 Reaktion ·
-
bug p:3-mid pydanty:bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
pydantic/pydantic-ai#8643 · 1 Kommentar ·