Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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:

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)

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.
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);

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.
I've tried to recompile sage -f matplotlib after export SAGE_MATPLOTLIB_GUI="yes"

            matplotlib: yes [1.4.3]
                python: yes [2.7.9 (default, Dec  3 2015, 20:58:38)  [GCC
              platform: yes [linux2]
                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
> locate
> locate

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