很长一段时间以来我一直在用
dfi.export(df1, "test.png")
将类型为pandas.io.formats.style.Styler的dataframe styler(df1)导出到. png。
今天我得到以下错误:
Traceback (most recent call last):
File ~\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py:3369 in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
Input In [48] in <cell line: 1>
dfi.export(df1, "ice_cotton_" + str(dashboard_date).split(" ")[0])
File ~\Anaconda3\lib\site-packages\dataframe_image\_pandas_accessor.py:48 in export
return _export(
File ~\Anaconda3\lib\site-packages\dataframe_image\_pandas_accessor.py:117 in _export
img_str = converter(html)
File ~\Anaconda3\lib\site-packages\dataframe_image\_screenshot.py:188 in run
img = self.take_screenshot()
File ~\Anaconda3\lib\site-packages\dataframe_image\_screenshot.py:140 in take_screenshot
img = mimage.imread(buffer)
File ~\Anaconda3\lib\site-packages\matplotlib\image.py:1560 in imread
with img_open(fname) as image:
File ~\Anaconda3\lib\site-packages\PIL\ImageFile.py:112 in __init__
self._open()
File ~\Anaconda3\lib\site-packages\PIL\PngImagePlugin.py:676 in _open
raise SyntaxError("not a PNG file")
File <string>
SyntaxError: not a PNG file
我该怎么解决这个问题?
1条答案
按热度按时间nhaq1z211#
这是一组可能的解决方案,只有最后一个对我有效:
1.使用后端,例如'mpl.use(' ps ')'
1.上一版本的Chrome(即1月27日;109.0.5414.119):这个管用!