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.

Possible Windows-only error on save() to PNG

See original GitHub issue

Getting 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. image

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:open
  • Created 3 years ago
  • Comments:17 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dkruszewcommented, Nov 10, 2020

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 the altair_saver package, which indicated that the error statement I was receiving was likely due to the below if statement failing for each saver method:

for s in _SAVER_METHODS.values():
    if s.enabled() and fmt in s.valid_formats[mode]:
        return s
raise ValueError(f"No enabled saver found that supports format={fmt!r}")

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 the png string was fine, and the issue appeared to exist within s.enabled(). I did some further digging where I played with the method and webdriver arguments in the save function. When respectively using method=selenium with webdriver=chrome I received an error that told me my chromedriver.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.

0reactions
jhermanncommented, Jul 31, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

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