Open stefan-kzmnv opened 1 year ago
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.
This, or some variant of it, is the correct fix. Because matplotlib.pyplot
is not explicitly imported, it may or may not exist at the time of this call, depending on what previous code did. The simplest change would be:
if close and Gcf.get_all_fig_managers():
+ import matplotlib.pyplot
matplotlib.pyplot.close('all')
@QuLogic That suggested fix won't work, as in the original example the matplotlib
module was overwritten silently by librosa, due to their implementation of lazy loading. See here for details.
In particular, as long as import matplotlib
is present first, adding import matplotlib.pyplot
won't work. However, it appears addingimport matplotlib.pyplot as plt
does work (for reasons that surpass my mortal understanding).
While I think such an import should be added (as per your fix), the issue is really upstream with librosa, so I've filed an issue there.
While attempting to create a piano roll with librosa and matplotlib, like this:
I encounter this error:
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.