question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name '_png' from 'matplotlib'

See original GitHub issue

Hi, 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:closed
  • Created 3 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

28reactions
aprilahijriyancommented, Oct 19, 2020

try this pip install matplotlib==3.1.3 work for me

16reactions
mschroencommented, Jul 20, 2021

Why is this issue closed? There should be a solution which works for latest matplotlib versions. Downgrading for most people is not an option.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot import name '_png' from 'matplotlib' - Stack Overflow
When I started the code I got from matplotlib import _png ImportError: cannot import name '_png' from 'matplotlib' ...
Read more >
cannot import name '_png' from 'matplotlib - You.com | The AI ...
When I started the code I got from matplotlib import _png ImportError: cannot import name '_png' from 'matplotlib' (D:\PyCharmProjects\kivyApp\venv\lib\site- ...
Read more >
" cannot import name '_png' from 'matplotlib'" versus - Reddit
Trying to launch kivy app from command prompt: " cannot import name '_png' from 'matplotlib'" versus. Dell Latitude, Windows 10, python 3.9. To ......
Read more >
How to Fix : “ImportError: Cannot import name X” in Python?
You can solve the “ ImportError : Cannot import name X” Error by resolving the circular dependencies. You can do that either by...
Read more >
Designer -Python Matplotlib error - Alteryx Community
I can import the package Matplotlib using; import matplotlib.pyplot ... pil_kwargs : dict, optional ImportError: cannot import name '_png'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found