ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 26 Feb 2018 12:16:26 -0600SageMath and interact / ipywidgets with jupyterhttp://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.]j.c.Mon, 26 Feb 2018 12:16:26 -0600http://ask.sagemath.org/question/41269/Sage on Jupyter with ipywidgets, matplotlibhttp://ask.sagemath.org/question/31326/sage-on-jupyter-with-ipywidgets-matplotlib/Hi all,
I've spent about two days now trying to get Sage to work nicely on Jupyter.
Still, I have the following two problems:<br /><br />
1. ipywidgets (and I have found no docu on the web that would hint to this problem) does not show any output and fails on commands like interact(f,x=10)<br /><br />
2. backend support for matplotlib (I've tried all the "solutions" that come up on a google search, I have tk/tcl installed on my system, sage compiled from scratch with $SAGE_MATPLOTLIB_GUI="yes" but it does not find TKInter for tk support, not to mention that the sage pyqt4 package fails compiling)
**concerning 1.**<br />
I ran the following code on jupyter with Sage 6.9 kernel
from __future__ import print_function;
from ipywidgets import interact;
def f(x): return(x);
interact(f,x=10);
this gives (besides various traceback output)
ValueError: 10 cannot be transformed to a Widget
I have the following version:
sage -installed | grep ipywidgets
ipywidgets.............................. 4.0.2
**concerning 2.**<br />
I've tried to recompile sage -f matplotlib after export SAGE_MATPLOTLIB_GUI="yes"
BUILDING MATPLOTLIB
matplotlib: yes [1.4.3]
python: yes [2.7.9 (default, Dec 3 2015, 20:58:38) [GCC
4.8.4]]
platform: yes [linux2]
...
OPTIONAL BACKEND EXTENSIONS
macosx: no [Mac OS-X only]
qt5agg: no [PyQt5 not found]
qt4agg: no [PyQt4 not found]
pyside: no [PySide not found]
gtk3agg: no [Requires pygobject to be installed.]
gtk3cairo: no [Requires cairocffi or pycairo to be installed.]
gtkagg: no [Requires pygtk]
tkagg: no [TKAgg requires Tkinter.]
wxagg: no [requires wxPython]
gtk: no [Requires pygtk]
agg: yes [installing]
cairo: no [cairocffi or pycairo not found]
windowing: no [Microsoft Windows only]
running on:
> uname -a
Linux host 3.16.0-53-generic #72~14.04.1-Ubuntu SMP Fri Nov 6 18:17:23 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
> locate libtk8.6.so
/usr/lib/x86_64-linux-gnu/libtk8.6.so
> locate libtcl8.6.so
/usr/lib/x86_64-linux-gnu/libtcl8.6.so
> locate Tkinter.py
/usr/lib/python2.7/lib-tk/Tkinter.py
/usr/lib/python2.7/lib-tk/Tkinter.pyc
Furthermore, (on another machine for some magic reason I could not figure out, I have TKAgg as backend available), it seems I cannot use %matplotlib inline as with a python kernel. The only option seems to have the plots in a new window.
Can anybody help? I'm frustrated to the point that I'm nearly planning on using the Python kernel and running the needed sage code via exec. But, quite honestly, that would be horrendous ;-)camoldFri, 04 Dec 2015 12:27:10 -0600http://ask.sagemath.org/question/31326/