ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 25 Jul 2016 09:42:04 -0500Sage on Jupyter with ipywidgets, matplotlibhttps://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 ;-)Fri, 04 Dec 2015 12:27:10 -0600https://ask.sagemath.org/question/31326/sage-on-jupyter-with-ipywidgets-matplotlib/Comment by mforets for <p>Hi all,</p>
<p>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)</p>
<p><strong>concerning 1.</strong><br/>
I ran the following code on jupyter with Sage 6.9 kernel</p>
<pre><code>from __future__ import print_function;
from ipywidgets import interact;
def f(x): return(x);
interact(f,x=10);
</code></pre>
<p>this gives (besides various traceback output)</p>
<pre><code>ValueError: 10 cannot be transformed to a Widget
</code></pre>
<p>I have the following version:</p>
<pre><code>sage -installed | grep ipywidgets
ipywidgets.............................. 4.0.2
</code></pre>
<p><strong>concerning 2.</strong><br/>
I've tried to recompile sage -f matplotlib after export SAGE_MATPLOTLIB_GUI="yes"</p>
<pre><code>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]
</code></pre>
<p>running on:</p>
<pre><code>> 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
</code></pre>
<p>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.</p>
<p>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 ;-)</p>
https://ask.sagemath.org/question/31326/sage-on-jupyter-with-ipywidgets-matplotlib/?comment=34216#post-id-34216if you don't have time, do ```plt.savefig('test.pdf')``` (instead of ```plt.show()```); it creates the file in the project's working directory.Mon, 25 Jul 2016 09:42:04 -0500https://ask.sagemath.org/question/31326/sage-on-jupyter-with-ipywidgets-matplotlib/?comment=34216#post-id-34216Comment by vdelecroix for <p>Hi all,</p>
<p>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)</p>
<p><strong>concerning 1.</strong><br/>
I ran the following code on jupyter with Sage 6.9 kernel</p>
<pre><code>from __future__ import print_function;
from ipywidgets import interact;
def f(x): return(x);
interact(f,x=10);
</code></pre>
<p>this gives (besides various traceback output)</p>
<pre><code>ValueError: 10 cannot be transformed to a Widget
</code></pre>
<p>I have the following version:</p>
<pre><code>sage -installed | grep ipywidgets
ipywidgets.............................. 4.0.2
</code></pre>
<p><strong>concerning 2.</strong><br/>
I've tried to recompile sage -f matplotlib after export SAGE_MATPLOTLIB_GUI="yes"</p>
<pre><code>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]
</code></pre>
<p>running on:</p>
<pre><code>> 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
</code></pre>
<p>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.</p>
<p>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 ;-)</p>
https://ask.sagemath.org/question/31326/sage-on-jupyter-with-ipywidgets-matplotlib/?comment=31327#post-id-31327have you read [question 11347](http://ask.sagemath.org/question/11347)Fri, 04 Dec 2015 13:32:58 -0600https://ask.sagemath.org/question/31326/sage-on-jupyter-with-ipywidgets-matplotlib/?comment=31327#post-id-31327