Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Altair use in VS Code with Interactive Python Extension broken

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)'
)
like image 775
hathawayj Avatar asked Oct 18 '25 15:10

hathawayj


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.

like image 185
jakevdp Avatar answered Oct 21 '25 05:10

jakevdp