Altair use in VS Code with Interactive Python Extension broken

Viewed 900

Today I tried to create an Altair chart in VS Code and it would not display. The code either runs with no output or returns the following error. Another friend has the same issue starting today.

Error loading script: Script error for "vega-util", needed by: vega-embed https://requirejs.org/docs/errors.html#scripterror

I can still save charts using altair-saver. Are there any other uses of VS Code with Altair having an issue?

Using https://altair-viz.github.io/gallery/simple_line_chart.html has the issue.

# %%
import altair as alt
import numpy as np
import pandas as pd

x = np.arange(100)
source = pd.DataFrame({
  'x': x,
  'f(x)': np.sin(x / 5)
})

alt.Chart(source).mark_line().encode(
    x='x',
    y='f(x)'
)
1 Answers

See vega/vega-embed#557; the error was due to a faulty vega-embed release which has now been fixed. Clear your javascript cache and it should load the updated version of vega-embed and work properly again.

Related