Possible Windows-only error on save() to PNG
See original GitHub issueGetting an error using Altair saver when I am trying to save a chart to a PNG in Jupyter Notebook: ValueError: Unsupported format: 'png'
Answer here on Stack Overflow suggested filing a bug report.
System info:
Windows 10 conda 4.8.2 Python 3.8.3 altair 4.1.0 py_1 conda-forge altair_saver 0.1.0 py_0 conda-forge vega 3.4.0 py38h32f6830_0 conda-forge selenium 3.141.0 py38h9de7a3e_1001 conda-forge
Example Code:
import pandas as pd
import altair as alt
from altair_saver import save
alt.renderers.enable('default'); # if in jupyter, ; to suppress output
alt.renderers.enable('altair_saver', fmts=['vega-lite', 'png']);
mytaskbars = pd.DataFrame([
{"task": "Task1a", "start": '2020-06-01', "end": '2020-09-30', "color": 'royalblue'},
{"task": "Task1b", "start": '2020-06-01', "end": '2021-03-31', "color": 'deepskyblue'},
{"task": "Task2", "start": '2020-06-01', "end": '2021-03-31', "color": 'red'},
])
mytaskbars["start"] = pd.to_datetime(mytaskbars["start"])
mytaskbars["end"] = pd.to_datetime(mytaskbars["end"])
chart = alt.Chart(mytaskbars).mark_bar(opacity=0.7).encode(
x=alt.X('start', axis=alt.Axis(title='Date', labelAngle=-45, format = ("%b %Y"))),
x2 = 'end',
y=alt.Y('task', axis=alt.Axis(title=None)),
color = alt.Color('color:N', scale = None)
)
save(chart, "chart_202006.png")
chart
Error Message:
ValueError Traceback (most recent call last)
<ipython-input-3-13a284c2aca9> in <module>
19 )
20
---> 21 save(chart, "chart_202006.png")
22 chart
~\anaconda3\envs\geospat_env\lib\site-packages\altair_saver\_core.py in save(chart, fp, fmt, mode, method, **kwargs)
60 """
61 if method is None:
---> 62 Saver = _get_saver_for_format(fmt=fmt, fp=fp)
63 elif isinstance(method, type):
64 Saver = method
~\anaconda3\envs\geospat_env\lib\site-packages\altair_saver\_core.py in _get_saver_for_format(fmt, fp)
28 if fmt in s.valid_formats and s.enabled():
29 return s
---> 30 raise ValueError(f"Unsupported format: {fmt!r}")
31
32
ValueError: Unsupported format: 'png'
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (3 by maintainers)
Top Results From Across the Web
Error when trying to view .png files: "windows photo viewer
The offending image is called "81902538" and when opened in Photoshop shows the file accurately, when saving the file as a new PNG...
Read more >c# - Bug in Windows /.NET's System.Drawing.Save(Stream ...
Save(Stream, Imageformat) creates corrupt PNG images. ... The problem only occurs if the resulting PNG-file size in bytes is 0x1001C + n ...
Read more >Tested Solutions: Can't Open PNG Files on Windows 10/11?
After opening the file, click on the file menu and then Save As. You can then select the file format you want to...
Read more >Fixed: It Looks Like You Don't Have Permission to Save ...
How to Fix It Looks Like You Don't Have Permission to Save Changes to This File · 1. Unblock the Picture · 2....
Read more >Save plot or graphics content to file - MATLAB exportgraphics
I = imread('peppers.png'); imshow(I) ax = gca; exportgraphics(ax ... Then save the contents of the axes as a PDF containing only vector graphics....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I encountered the same issue while running the
altair_saver.save()
function on my Windows 10 machine: i.e this error:No enabled saver found that supports format='png'
.Investigating the error led me to the below code within
_core.py
in thealtair_saver
package, which indicated that the error statement I was receiving was likely due to the below if statement failing for each saver method:I originally thought that the above if statements were failing because of the file format
png in s.valid_formats[mode]
. Upon investigation I discovered thepng
string was fine, and the issue appeared to exist withins.enabled()
. I did some further digging where I played with themethod
andwebdriver
arguments in thesave
function. When respectively usingmethod=selenium
withwebdriver=chrome
I received an error that told me mychromedriver.exe
file was out of date for my chrome browser. I re-downloaded from here and replaced the file in C:\Windows. After doing so the save function worked seamlessly.You need to find out the difference in your shell env vs. the systemd one – starting with the fact you run this as root. If you try the
ExecStart
command in a root shell that might enlighten you as to a cause.Or look into systemd user services and run as
vtn-bot
.