Altair does not work in the classic Jupyter Notebook after successfully using it in an nteract web notebook.
Altair works in nteract without a user needing to run alt.renderers.enable('notebook'). e.g. this notebook works https://github.com/nteract/nteract/blob/master/applications/desktop/example-notebooks/altair.ipynb when launched with jupyter nteract.
When using Altair without nteract, a user must run alt.renderers.enable('notebook'). However, this returns the below error. As per the Altair troubleshooting guide, Altair believes Vega is not installed. Even upon verifying successful Altair + Vega installation (as per the installation guide ), the error persists. conda list verified Vega is installed. I am using Jupyter Notebook 5.6.0.
Do you know what may be causing this?
cc @rgbkrk
---------------------------------------------------------------------------
NoSuchEntryPoint Traceback (most recent call last)
~/anaconda3/lib/python3.6/site-packages/altair/utils/plugin_registry.py in _enable(self, name, **options)
133 try:
--> 134 ep = entrypoints.get_single(self.entry_point_group, name)
135 except entrypoints.NoSuchEntryPoint:
~/anaconda3/lib/python3.6/site-packages/entrypoints.py in get_single(group, name, path)
185
--> 186 raise NoSuchEntryPoint(group, name)
187
NoSuchEntryPoint: No 'notebook' entry point found in group 'altair.vegalite.v2.renderer'
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-4-025c0cf17452> in <module>()
----> 1 alt.renderers.enable('notebook')
~/anaconda3/lib/python3.6/site-packages/altair/utils/plugin_registry.py in enable(self, name, **options)
169 if name is None:
170 name = self.active
--> 171 return PluginEnabler(self, name, **options)
172
173
~/anaconda3/lib/python3.6/site-packages/altair/utils/plugin_registry.py in __init__(self, registry, name, **options)
23 self.options = options
24 self.original_state = registry._get_state()
---> 25 self.registry._enable(name, **options)
26
27 def __enter__(self):
~/anaconda3/lib/python3.6/site-packages/altair/utils/plugin_registry.py in _enable(self, name, **options)
135 except entrypoints.NoSuchEntryPoint:
136 if name in self.entrypoint_err_messages:
--> 137 raise ValueError(self.entrypoint_err_messages[name])
138 else:
139 raise
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.
You need to pip install vega==1.3. vega version 2.0 does not work with the current release of Altair. See #1114
@jakevdp Thank you. Success.
(FYI to others that may find themselves here -- alt.renderers.enable('notebook') is not still required in nteract for successful load)
alt.renderers.enable('notebook') is not still required in nteract for successful load)
The notebook renderer was never required for nteract. Where did you hear that? I'd like to correct that information if it's out there somewhere.
This is the result of my misunderstanding rather than explicit instruction.
Note this notebook, which is meant to be loaded in nteract, displays
If you see this message, it means the renderer has not been properly enabled
for the frontend that you are using. For more information, see
https://altair-viz.github.io/user_guide/troubleshooting.html
when rendered on GitHub.
I see. Maybe it would be useful to add some nteract-specific information to https://altair-viz.github.io/user_guide/troubleshooting.html and to https://altair-viz.github.io/getting_started/installation.html ?
I've never used nteract, so I don't have the background to be able to add relevant details. A doc contribution would be welcome – the source is here: https://github.com/altair-viz/altair/blob/master/doc/getting_started/installation.rst
Also, the reason github shows that message rather than a plot is because it scrubs all javascript output. In jupyter notebook and jupyterlab, the respective vega extension is set up to cache a png preview of every rendered plot as a fallback for github, nbviewer, and other non-js-enabled notebook views.
Maybe nteract could add that feature as well to avoid this confusion?
In jupyter notebook and jupyterlab, the respective vega extension is set up to cache a png preview of every rendered plot as a fallback for github, nbviewer, and other non-js-enabled notebook views.
Maybe nteract could add that feature as well to avoid this confusion?
I'll do some thinking on that. We've largely kept rendering pure, assuming that we'd only report what kernels provide. 🤔 I could see a way of us handling it in the future.
When the plots are interactive, do you store the changed result?
When the plots are interactive, do you store the changed result?
No, the PNG is rendered at the time the plot is displayed. You can see the source here: https://github.com/vega/ipyvega/blob/master/src/index.ts#L22-L35
Most helpful comment
You need to
pip install vega==1.3. vega version 2.0 does not work with the current release of Altair. See #1114