ImportError: cannot import name '_png' from 'matplotlib'
See original GitHub issueHi, while trying out the fbprophet tutorial, I encountered the following error log when attempting to execute in jupyter notebook the following code: fig1 = m.plot(forecast)
The error log is as follows:
ImportError Traceback (most recent call last) ~/opt/anaconda3/lib/python3.7/site-packages/IPython/core/formatters.py in call(self, obj) 339 pass 340 else: –> 341 return printer(obj) 342 # Finally look for special method names 343 method = get_real_method(obj, self.print_method)
~/opt/anaconda3/lib/python3.7/site-packages/IPython/core/pylabtools.py in <lambda>(fig) 246 247 if ‘png’ in formats: –> 248 png_formatter.for_type(Figure, lambda fig: print_figure(fig, ‘png’, **kwargs)) 249 if ‘retina’ in formats or ‘png2x’ in formats: 250 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))
~/opt/anaconda3/lib/python3.7/site-packages/IPython/core/pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs) 130 FigureCanvasBase(fig) 131 –> 132 fig.canvas.print_figure(bytes_io, **kw) 133 data = bytes_io.getvalue() 134 if fmt == ‘svg’:
~/opt/anaconda3/lib/python3.7/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, **kwargs) 2092 hardcopy. 2093 -> 2094 Parameters 2095 ---------- 2096 filename : str or path-like or file-like
~/opt/anaconda3/lib/python3.7/site-packages/matplotlib/backend_bases.py in _get_renderer(figure, print_method) 1558 return renderer 1559 else: -> 1560 raise RuntimeError(f"{print_method} did not call Figure.draw, so " 1561 f"no renderer is available") 1562 finally:
~/opt/anaconda3/lib/python3.7/site-packages/matplotlib/backends/backend_agg.py in print_png(self, filename_or_obj, metadata, pil_kwargs, *args, **kwargs)
503 pil_kwargs : dict, optional
504 Keyword arguments passed to PIL.Image.Image.save
.
–> 505
506 If the ‘pnginfo’ key is present, it completely overrides
507 metadata, including the default ‘Software’ key.
ImportError: cannot import name ‘_png’ from ‘matplotlib’ (/Users/jasonchia/opt/anaconda3/lib/python3.7/site-packages/matplotlib/init.py)
I tried updating matplotlib to 3.3.2 but the problem still persists. Please advise, am in need of urgent assistance…Thanks in advance.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (1 by maintainers)
Top GitHub Comments
try this
pip install matplotlib==3.1.3
work for meWhy is this issue closed? There should be a solution which works for latest matplotlib versions. Downgrading for most people is not an option.