简体   繁体   中英

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)'
)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM