问题描述
我试图使用Altpy与Jupyter Notebook一起工作,
Trying to get Altair to work with Jupyter Notebook, I installed it using
conda install -c conda-forge altair vega_datasets notebook vega
但是当我尝试绘制示例图时
But when I try to do an example plot
import altair as alt
from vega_datasets import data
# for the notebook only (not for JupyterLab) run this command once per session
alt.renderers.enable('notebook')
iris = data.iris()
alt.Chart(iris).mark_point().encode(
x='petalLength',
y='petalWidth',
color='species'
)
在他们的快速入门指南中可以看到
ValueError:
To use the 'notebook' renderer, you must install the vega package
and the associated Jupyter extension.
See https://altair-viz.github.io/getting_started/installation.html
for more information.
即使我已经使用Conda安装了vega.我可以制作维加示例图.我无法启用Jupyter扩展,因为Jupyter说它不兼容.
even though I have installed vega using Conda. I can make vega example plots though. I am unable to enable the Jupyter extension though, as Jupyter says it is incompatible.
感谢您的帮助.
推荐答案
对于最新版本的altair(2.2版),请使用
For the current release of altair (Version 2.2), use
conda install -c conda-forge vega=1.3
或
pip install vega==1.3
然后重新启动笔记本电脑.
and then restart the notebook.
vega
python扩展本周错误地更新为仅支持vega-lite 3.0,该版本尚未发布,因此Altair尚不支持.
The vega
python extension was mistakenly updated this week to only support vega-lite 3.0, which is not yet released and thus not yet supported by Altair.
请参见 https://github.com/altair-viz/altair/issues/1114 以获得初始错误报告.
See https://github.com/altair-viz/altair/issues/1114 for the initial bug report.
这篇关于让Altair与Jupyter Notebook一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!