ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 02 Mar 2018 17:24:10 +0100SageMath and interact / ipywidgets with jupyterhttps://ask.sagemath.org/question/41269/sagemath-and-interact-ipywidgets-with-jupyter/I got the SageMath kernel working well inside my anaconda distribution's copy of jupyter, following [these instructions](https://stackoverflow.com/a/41595015), so I can open SageMath notebooks using anaconda jupyter and they run perfectly fine -- almost.
I would like to get interact elements / ipywidgets working when I use SageMath as a kernel in anaconda jupyter, but with my current configuration (hopefully described in sufficient detail below), I get the following error message in the console
>[IPKernelApp] WARNING | Widget Javascript not detected. It may not be installed or enabled properly.
and the notebook simply outputs the initial value of the function with no interactivity.
---
I'm running SageMath 8.1 on macOS. I've been able to get interact elements and ipywidgets with SageMath code running in the SageMath jupyter notebook interface (not sure if this was necessary, but I ran
`/local/bin/jupyter nbextension enable --py widgetsnbextension`
in the SageMath directory.) Everything works as expected, i.e. if I run `sagemath -n jupyter` and open a notebook containing:
>import ipywidgets as widgets
>
>widgets.IntSlider(
value=7,
min=0,
max=10,
step=1,
description='Test:',
disabled=False,
continuous_update=False,
orientation='horizontal',
readout=True,
readout_format='d'
)
I get a slider widget which works.
Similarly, examples from this [interact tutorial](https://wiki.sagemath.org/interact/graphics) on the SageMath wiki run perfectly fine in SageMath jupyter.
I also have an up-to-date anaconda install of jupyter where the ipywidgets nbextension has been enabled; the above ipywidgets code can be run in anaconda jupyter with the ordinary python kernel and works fine.
----
[The real reason I am asking this question is I would like to figure out how to get interactive widgets working in jupyterlab with the SageMath kernel, but I'm guessing that if the above question can be answered, I can get everything else working as well.]Mon, 26 Feb 2018 19:16:26 +0100https://ask.sagemath.org/question/41269/sagemath-and-interact-ipywidgets-with-jupyter/Comment by Jeroen Demeyer for <p>I got the SageMath kernel working well inside my anaconda distribution's copy of jupyter, following <a href="https://stackoverflow.com/a/41595015">these instructions</a>, so I can open SageMath notebooks using anaconda jupyter and they run perfectly fine -- almost.</p>
<p>I would like to get interact elements / ipywidgets working when I use SageMath as a kernel in anaconda jupyter, but with my current configuration (hopefully described in sufficient detail below), I get the following error message in the console</p>
<blockquote>
<p>[IPKernelApp] WARNING | Widget Javascript not detected. It may not be installed or enabled properly.</p>
</blockquote>
<p>and the notebook simply outputs the initial value of the function with no interactivity.</p>
<hr>
<p>I'm running SageMath 8.1 on macOS. I've been able to get interact elements and ipywidgets with SageMath code running in the SageMath jupyter notebook interface (not sure if this was necessary, but I ran </p>
<p><code>/local/bin/jupyter nbextension enable --py widgetsnbextension</code></p>
<p>in the SageMath directory.) Everything works as expected, i.e. if I run <code>sagemath -n jupyter</code> and open a notebook containing:</p>
<blockquote>
<p>import ipywidgets as widgets</p>
<p>widgets.IntSlider(
value=7,
min=0,
max=10,
step=1,
description='Test:',
disabled=False,
continuous_update=False,
orientation='horizontal',
readout=True,
readout_format='d'
)</p>
</blockquote>
<p>I get a slider widget which works.</p>
<p>Similarly, examples from this <a href="https://wiki.sagemath.org/interact/graphics">interact tutorial</a> on the SageMath wiki run perfectly fine in SageMath jupyter.</p>
<p>I also have an up-to-date anaconda install of jupyter where the ipywidgets nbextension has been enabled; the above ipywidgets code can be run in anaconda jupyter with the ordinary python kernel and works fine.</p>
<hr>
<p>[The real reason I am asking this question is I would like to figure out how to get interactive widgets working in jupyterlab with the SageMath kernel, but I'm guessing that if the above question can be answered, I can get everything else working as well.]</p>
https://ask.sagemath.org/question/41269/sagemath-and-interact-ipywidgets-with-jupyter/?comment=41325#post-id-41325Just something to try: does the working directory make a difference? Could you try running the Sage-Jupyter-in-anaconda from the Sage root directory?Thu, 01 Mar 2018 10:02:56 +0100https://ask.sagemath.org/question/41269/sagemath-and-interact-ipywidgets-with-jupyter/?comment=41325#post-id-41325Answer by Jeroen Demeyer for <p>I got the SageMath kernel working well inside my anaconda distribution's copy of jupyter, following <a href="https://stackoverflow.com/a/41595015">these instructions</a>, so I can open SageMath notebooks using anaconda jupyter and they run perfectly fine -- almost.</p>
<p>I would like to get interact elements / ipywidgets working when I use SageMath as a kernel in anaconda jupyter, but with my current configuration (hopefully described in sufficient detail below), I get the following error message in the console</p>
<blockquote>
<p>[IPKernelApp] WARNING | Widget Javascript not detected. It may not be installed or enabled properly.</p>
</blockquote>
<p>and the notebook simply outputs the initial value of the function with no interactivity.</p>
<hr>
<p>I'm running SageMath 8.1 on macOS. I've been able to get interact elements and ipywidgets with SageMath code running in the SageMath jupyter notebook interface (not sure if this was necessary, but I ran </p>
<p><code>/local/bin/jupyter nbextension enable --py widgetsnbextension</code></p>
<p>in the SageMath directory.) Everything works as expected, i.e. if I run <code>sagemath -n jupyter</code> and open a notebook containing:</p>
<blockquote>
<p>import ipywidgets as widgets</p>
<p>widgets.IntSlider(
value=7,
min=0,
max=10,
step=1,
description='Test:',
disabled=False,
continuous_update=False,
orientation='horizontal',
readout=True,
readout_format='d'
)</p>
</blockquote>
<p>I get a slider widget which works.</p>
<p>Similarly, examples from this <a href="https://wiki.sagemath.org/interact/graphics">interact tutorial</a> on the SageMath wiki run perfectly fine in SageMath jupyter.</p>
<p>I also have an up-to-date anaconda install of jupyter where the ipywidgets nbextension has been enabled; the above ipywidgets code can be run in anaconda jupyter with the ordinary python kernel and works fine.</p>
<hr>
<p>[The real reason I am asking this question is I would like to figure out how to get interactive widgets working in jupyterlab with the SageMath kernel, but I'm guessing that if the above question can be answered, I can get everything else working as well.]</p>
https://ask.sagemath.org/question/41269/sagemath-and-interact-ipywidgets-with-jupyter/?answer=41335#post-id-41335And I forgot the obvious: clear your browser cache! You might be using a cached newer version of the widgets JavaScript.Thu, 01 Mar 2018 17:13:57 +0100https://ask.sagemath.org/question/41269/sagemath-and-interact-ipywidgets-with-jupyter/?answer=41335#post-id-41335Answer by j.c. for <p>I got the SageMath kernel working well inside my anaconda distribution's copy of jupyter, following <a href="https://stackoverflow.com/a/41595015">these instructions</a>, so I can open SageMath notebooks using anaconda jupyter and they run perfectly fine -- almost.</p>
<p>I would like to get interact elements / ipywidgets working when I use SageMath as a kernel in anaconda jupyter, but with my current configuration (hopefully described in sufficient detail below), I get the following error message in the console</p>
<blockquote>
<p>[IPKernelApp] WARNING | Widget Javascript not detected. It may not be installed or enabled properly.</p>
</blockquote>
<p>and the notebook simply outputs the initial value of the function with no interactivity.</p>
<hr>
<p>I'm running SageMath 8.1 on macOS. I've been able to get interact elements and ipywidgets with SageMath code running in the SageMath jupyter notebook interface (not sure if this was necessary, but I ran </p>
<p><code>/local/bin/jupyter nbextension enable --py widgetsnbextension</code></p>
<p>in the SageMath directory.) Everything works as expected, i.e. if I run <code>sagemath -n jupyter</code> and open a notebook containing:</p>
<blockquote>
<p>import ipywidgets as widgets</p>
<p>widgets.IntSlider(
value=7,
min=0,
max=10,
step=1,
description='Test:',
disabled=False,
continuous_update=False,
orientation='horizontal',
readout=True,
readout_format='d'
)</p>
</blockquote>
<p>I get a slider widget which works.</p>
<p>Similarly, examples from this <a href="https://wiki.sagemath.org/interact/graphics">interact tutorial</a> on the SageMath wiki run perfectly fine in SageMath jupyter.</p>
<p>I also have an up-to-date anaconda install of jupyter where the ipywidgets nbextension has been enabled; the above ipywidgets code can be run in anaconda jupyter with the ordinary python kernel and works fine.</p>
<hr>
<p>[The real reason I am asking this question is I would like to figure out how to get interactive widgets working in jupyterlab with the SageMath kernel, but I'm guessing that if the above question can be answered, I can get everything else working as well.]</p>
https://ask.sagemath.org/question/41269/sagemath-and-interact-ipywidgets-with-jupyter/?answer=41345#post-id-41345I asked this question on the [ipywidgets github page](https://github.com/jupyter-widgets/ipywidgets/issues/1989) and was able to solve this issue.
In short, as explained to me on github, the version of ipywidgets that comes installed with SageMath 8.1 (version 6.0.0) is too old to interface with the widgetsnbextension that anaconda jupyter was using. The solution was to upgrade SageMath's ipywidgets package.
I first had to install ssl in sage first, which I did by following [the instructions in this thread](https://groups.google.com/forum/#!topic/sage-support/c2fm64j55Jk). I ran the following commands in order:
>sage -i openssl
>sage -f python2
>sage -i pyopenssl
After about 2 hours of rebuilding, this step was complete and then I ran the following pip command to upgrade ipywidgets and all of its dependencies for Sage:
sage -pip install --upgrade ipywidgets
This completed successfully, so I did some testing and ipywidgets (and interact) elements now work perfectly in my anaconda jupyter notebook when I use the SageMath kernel.
They also work when I use the SageMath kernel in jupyterlab as well.Fri, 02 Mar 2018 00:03:36 +0100https://ask.sagemath.org/question/41269/sagemath-and-interact-ipywidgets-with-jupyter/?answer=41345#post-id-41345Comment by slelievre for <p>I asked this question on the <a href="https://github.com/jupyter-widgets/ipywidgets/issues/1989">ipywidgets github page</a> and was able to solve this issue.</p>
<p>In short, as explained to me on github, the version of ipywidgets that comes installed with SageMath 8.1 (version 6.0.0) is too old to interface with the widgetsnbextension that anaconda jupyter was using. The solution was to upgrade SageMath's ipywidgets package. </p>
<p>I first had to install ssl in sage first, which I did by following <a href="https://groups.google.com/forum/#!topic/sage-support/c2fm64j55Jk">the instructions in this thread</a>. I ran the following commands in order:</p>
<blockquote>
<p>sage -i openssl</p>
<p>sage -f python2</p>
<p>sage -i pyopenssl</p>
</blockquote>
<p>After about 2 hours of rebuilding, this step was complete and then I ran the following pip command to upgrade ipywidgets and all of its dependencies for Sage:
sage -pip install --upgrade ipywidgets</p>
<p>This completed successfully, so I did some testing and ipywidgets (and interact) elements now work perfectly in my anaconda jupyter notebook when I use the SageMath kernel. </p>
<p>They also work when I use the SageMath kernel in jupyterlab as well.</p>
https://ask.sagemath.org/question/41269/sagemath-and-interact-ipywidgets-with-jupyter/?comment=41361#post-id-41361Well done. You should accept your own answer to mark your question as solved.Fri, 02 Mar 2018 15:14:44 +0100https://ask.sagemath.org/question/41269/sagemath-and-interact-ipywidgets-with-jupyter/?comment=41361#post-id-41361Comment by slelievre for <p>I asked this question on the <a href="https://github.com/jupyter-widgets/ipywidgets/issues/1989">ipywidgets github page</a> and was able to solve this issue.</p>
<p>In short, as explained to me on github, the version of ipywidgets that comes installed with SageMath 8.1 (version 6.0.0) is too old to interface with the widgetsnbextension that anaconda jupyter was using. The solution was to upgrade SageMath's ipywidgets package. </p>
<p>I first had to install ssl in sage first, which I did by following <a href="https://groups.google.com/forum/#!topic/sage-support/c2fm64j55Jk">the instructions in this thread</a>. I ran the following commands in order:</p>
<blockquote>
<p>sage -i openssl</p>
<p>sage -f python2</p>
<p>sage -i pyopenssl</p>
</blockquote>
<p>After about 2 hours of rebuilding, this step was complete and then I ran the following pip command to upgrade ipywidgets and all of its dependencies for Sage:
sage -pip install --upgrade ipywidgets</p>
<p>This completed successfully, so I did some testing and ipywidgets (and interact) elements now work perfectly in my anaconda jupyter notebook when I use the SageMath kernel. </p>
<p>They also work when I use the SageMath kernel in jupyterlab as well.</p>
https://ask.sagemath.org/question/41269/sagemath-and-interact-ipywidgets-with-jupyter/?comment=41362#post-id-41362Note that a more recent version of ipywidgets should make its way into Sage 8.2.
See [Sage trac ticket #23177: upgrade to ipywidgets 7](https://trac.sagemath.org/ticket/23177).
You can already try it out by installing the latest development release of Sage, Sage 8.2.beta6.Fri, 02 Mar 2018 15:18:13 +0100https://ask.sagemath.org/question/41269/sagemath-and-interact-ipywidgets-with-jupyter/?comment=41362#post-id-41362Comment by j.c. for <p>I asked this question on the <a href="https://github.com/jupyter-widgets/ipywidgets/issues/1989">ipywidgets github page</a> and was able to solve this issue.</p>
<p>In short, as explained to me on github, the version of ipywidgets that comes installed with SageMath 8.1 (version 6.0.0) is too old to interface with the widgetsnbextension that anaconda jupyter was using. The solution was to upgrade SageMath's ipywidgets package. </p>
<p>I first had to install ssl in sage first, which I did by following <a href="https://groups.google.com/forum/#!topic/sage-support/c2fm64j55Jk">the instructions in this thread</a>. I ran the following commands in order:</p>
<blockquote>
<p>sage -i openssl</p>
<p>sage -f python2</p>
<p>sage -i pyopenssl</p>
</blockquote>
<p>After about 2 hours of rebuilding, this step was complete and then I ran the following pip command to upgrade ipywidgets and all of its dependencies for Sage:
sage -pip install --upgrade ipywidgets</p>
<p>This completed successfully, so I did some testing and ipywidgets (and interact) elements now work perfectly in my anaconda jupyter notebook when I use the SageMath kernel. </p>
<p>They also work when I use the SageMath kernel in jupyterlab as well.</p>
https://ask.sagemath.org/question/41269/sagemath-and-interact-ipywidgets-with-jupyter/?comment=41363#post-id-41363Thanks for the info. I wasn't able to accept my own answer previously since I didn't have 50 points, but now I can.Fri, 02 Mar 2018 17:24:10 +0100https://ask.sagemath.org/question/41269/sagemath-and-interact-ipywidgets-with-jupyter/?comment=41363#post-id-41363