@interact command not working in Sage 7.3 & 7.4

221 views
Skip to first unread message

ahaus...@umassd.edu

unread,
Oct 23, 2016, 1:03:13 PM10/23/16
to sage-support
Hi the @interact command no longer seems to be working in Sage 7.3 and Sage 7.4 on an Mac Book Pro running El Capitan:

Here is the contents I entered in an "Jupyter" notebook cell which I copied from a Sage interact example:
-----------------------------------------------------------------------------------
Contents of the sage 7.4 notebook cell:
from ipywidgets import interact, interactive, fixed
import ipywidgets as widgets


@interact(num=5)
def square(num=2):
    print "{} squared is {}".format(num, num*num)
--------------------------------------------------------------------------------------------

Here is the error output: displayed in the output cell:
------------------------------------------------------------------------------------------------------
Traceback (most recent call last): print "{} squared is {}".format(num,
num*num) File "", line 1, in <module> File
"/private/var/folders/31/r_2f8ryd5ks7xb80nyrbj2cc0000gn/T/tmprIbuu6/___c
\ ode___.py", line 8, in <module> def square(num=_sage_const_2 ): File
\ 2.7/site-packages/ipywidgets/widgets/interaction.py", line 360, in dec
return interact(f, **kwargs) File
\ 2.7/site-packages/ipywidgets/widgets/interaction.py", line 343, in
interact w = interactive(f, **kwargs) File
\ 2.7/site-packages/ipywidgets/widgets/interaction.py", line 203, in
interactive container = Box(_dom_classes=['widget-interact']) File
\ 2.7/site-packages/ipywidgets/widgets/widget_box.py", line 44, in
__init__ super(Box, self).__init__(**kwargs) File
\ 2.7/site-packages/ipywidgets/widgets/domwidget.py", line 90, in
__init__ super(DOMWidget, self).__init__(*pargs, **kwargs) File
\ 2.7/site-packages/ipywidgets/widgets/widget.py", line 184, in __init__
self.open() File
\ 2.7/site-packages/ipywidgets/widgets/widget.py", line 197, in open
state, buffer_keys, buffers =
self._split_state_buffers(self.get_state()) File
\ 2.7/site-packages/ipywidgets/widgets/widget.py", line 291, in
get_state value = to_json(getattr(self, k), self) File
\ 2.7/site-packages/traitlets/traitlets.py", line 529, in __get__ return
self.get(obj, cls) File
\ 2.7/site-packages/traitlets/traitlets.py", line 508, in get value =
self._validate(obj, dynamic_default()) File
\ 2.7/site-packages/ipywidgets/widgets/domwidget.py", line 23, in
_layout_default return Layout() File
\ 2.7/site-packages/ipywidgets/widgets/widget.py", line 184, in __init__
self.open() File
\ 2.7/site-packages/ipywidgets/widgets/widget.py", line 203, in open
self.comm = Comm(**args) File
\ 2.7/site-packages/ipykernel/comm/comm.py", line 63, in __init__
self.open(data=data, metadata=metadata, buffers=buffers) File
\ 2.7/site-packages/ipykernel/comm/comm.py", line 94, in open
comm_manager = getattr(self.kernel, 'comm_manager', None) File
\ 2.7/site-packages/traitlets/traitlets.py", line 529, in __get__ return
self.get(obj, cls) File
\ 2.7/site-packages/traitlets/traitlets.py", line 508, in get value =
self._validate(obj, dynamic_default()) File
\ 2.7/site-packages/traitlets/traitlets.py", line 564, in _validate
value = self.validate(obj, value) File
\ 2.7/site-packages/traitlets/traitlets.py", line 1589, in validate
self.error(obj, value) File
\ 2.7/site-packages/traitlets/traitlets.py", line 1436, in error raise
TraitError(e) traitlets.traitlets.TraitError: The 'kernel' trait of a
Comm instance must be a Kernel, but a value of type 'NoneType' (i.e.
None) was specified.

----------------------------------------------------------------------------------------------------------------

Any ideas?

Regards,

Adam Hausknecht
Department of Mathematics
UMass Dartmouth


Sage7_4InteractProblem.txt

Jeroen Demeyer

unread,
Oct 23, 2016, 2:36:50 PM10/23/16
to sage-s...@googlegroups.com
On 2016-10-23 19:03, ahaus...@umassd.edu wrote:
> Hi the @interact command no longer seems to be working in Sage 7.3 and
> Sage 7.4 on an Mac Book Pro running El Capitan:

Works for me on Sage 7.5.beta0. In fact I did some @interact developed
recently and I never had a problem like that.

Interestingly, the error that you get is exactly the error when running
that code in the command-line (where interacts obviously don't work).

ahaus...@umassd.edu

unread,
Oct 23, 2016, 4:16:23 PM10/23/16
to sage-support
One idea: Could the an old version of the notebook be running instead of the Jupyter notebook? Note I am using the app version of Sage 7.4.  The menu at the top of screen indicates
that Jupyter is running.(I've attached a snap of Sage 7.4 notebook ).
Sage7_4NotebookSnap.pdf

Vincent Delecroix

unread,
Oct 23, 2016, 4:28:00 PM10/23/16
to sage-support
Your snapshot shows the "Sage notebook" and not the "Jupyter
notebook". I confirm that with sage-7.5 your code
* when executed in the Jupyter notebook (started with "sage
--notebook=jupyter") works fine
* when executed in the Sage notebook (started with "sage
--notebook=sagenb") ends with the same kind of error and traceback

On 23 October 2016 at 22:16, ahaus...@umassd.edu
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support...@googlegroups.com.
> To post to this group, send email to sage-s...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.

ahaus...@umassd.edu

unread,
Oct 23, 2016, 6:14:40 PM10/23/16
to sage-support


On Sunday, October 23, 2016 at 1:03:13 PM UTC-4, ahaus...@umassd.edu wrote:
By changing the name of the .sage directory in my home directory and restarting Sage 7.4,  I noticed that Sage 7.4
opens the Terminal app and enters the line

ast login: Sun Oct 23 18:04:25 on ttys000

Adam314:~ ahausknecht$ '/Applications/SageMath-7.4.app/Contents/Resources/sage/sage' --notebook=sagenb


which causes the old version of the notebook to start instead of the Jupyter notebook.  I changed the "sagenb" to "jupiter" and got the jupyter notebook to start BUT now my old Sage notebook files are
missing from the notebook home page. Where are they saved and how can I convert them to Jupyter notebooks?

Vincent Delecroix

unread,
Oct 24, 2016, 6:49:11 AM10/24/16
to sage-support
I think that they are stored in

.sage/sage_notebook.sagenb/

And thanks to Volker we have a converter in the last Sage releases

https://trac.sagemath.org/ticket/19877

Vincent

kcrisman

unread,
Oct 26, 2016, 6:02:18 PM10/26/16
to sage-support
That said, there are still some incompatibilities in interact syntax, the last I heard (Jason Grout said the jupyter people were working actively no that, though). 

Jeroen Demeyer

unread,
Oct 26, 2016, 6:58:39 PM10/26/16
to sage-s...@googlegroups.com
On 2016-10-27 00:02, kcrisman wrote:
> That said, there are still some incompatibilities in interact syntax,
> the last I heard (Jason Grout said the jupyter people were working
> actively no that, though).

In interact *syntax* or interact *functionality*? Of course, the
interact functionality is quite different, but that is fixed by
https://trac.sagemath.org/ticket/21267

ahaus...@umassd.edu

unread,
Oct 29, 2016, 8:03:16 PM10/29/16
to sage-support


On Sunday, October 23, 2016 at 1:03:13 PM UTC-4, ahaus...@umassd.edu wrote:
 Thanks for the answers!

However,  I still have the following questions:

1. How do you set SageMath 7.4 App so that it automatically starts up the Jupyter notebook?
 
    Even after renaming .sage, SageMath 7.4 App still opens using the old sage notebook and I need to use the command
    line to force the SageMath 7.4 App to open a Jupyter notebook. Also, even when SageMath 7.4 App opens the
    old sage notebook, the "Jupyter" item is checked in the menu displayed at the top of the screen. Why?

2. In the future will the SageMath Jupyter notebook have the same menus & buttons as the old sage notebook?

kcrisman

unread,
Oct 31, 2016, 10:17:08 PM10/31/16
to sage-support
Right, I knew that was being dealt with somewhere. 

kcrisman

unread,
Oct 31, 2016, 10:18:28 PM10/31/16
to sage-support


However,  I still have the following questions:

1. How do you set SageMath 7.4 App so that it automatically starts up the Jupyter notebook?

I don't think this is yet possible.  Not sure about the menu bar.
 
 
    Even after renaming .sage, SageMath 7.4 App still opens using the old sage notebook and I need to use the command
    line to force the SageMath 7.4 App to open a Jupyter notebook. Also, even when SageMath 7.4 App opens the
    old sage notebook, the "Jupyter" item is checked in the menu displayed at the top of the screen. Why?

2. In the future will the SageMath Jupyter notebook have the same menus & buttons as the old sage notebook?



Seems unlikely, since it is the Jupyter notebook not sagenb, and is maintained upstream elsewhere.  Perhaps this is a regression? 

ahaus...@umassd.edu

unread,
Nov 2, 2016, 12:38:09 AM11/2/16
to sage-support


On Sunday, October 23, 2016 at 1:03:13 PM UTC-4, ahaus...@umassd.edu wrote:
 I actually prefer the standard notebook because of its menus and buttons. My main problem is that my @interact examples that worked in Sage 6.XX (and even the examples in the current  SageMath documentation) no longer work in the SageMath 7.4 standard notebook . Also, when I attempted to use the Windows version of SageMath 7.4, it started up the Jupyter notebook instead of the old notebook. Will these problems be fixed in future versions of SageMath?
 

William Stein

unread,
Nov 2, 2016, 9:07:17 AM11/2/16
to sage-support
On Tue, Nov 1, 2016 at 9:38 PM, ahaus...@umassd.edu
<ahaus...@umassd.edu> wrote:
>
[...]
>> I actually prefer the standard notebook because of its menus and buttons.
>> My main problem is that my @interact examples that worked in Sage 6.XX (and
>> even the examples in the current SageMath documentation) no longer work in
>> the SageMath 7.4 standard notebook . Also, when I attempted to use the
>> Windows version of SageMath 7.4, it started up the Jupyter notebook instead
>> of the old notebook. Will these problems be fixed in future versions of
>> SageMath?

Fort what it is worth, your interact example works fine in
SageMathCloud worksheets -- see screenshot.

https://cloud.sagemath.com/projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/files/support/2016-11-02-interact.sagews

You could run SMC via Docker
https://github.com/sagemathinc/smc/blob/master/src/dev/docker/README.md

on Windows https://docs.docker.com/docker-for-windows/

---

Regarding what happened with the Sage distribution, nobody wanted to
maintain the old sage notebook, so people decided Sage should switch
to Jupyter, which is maintained and developed. Other people then
tried to implement something like Sage's @interact on top of what
Jupyter provides, but they evidently didn't do so sufficiently
robustly yet...

William
Screen Shot 2016-11-02 at 6.02.09 AM.png

kcrisman

unread,
Nov 2, 2016, 1:28:35 PM11/2/16
to sage-support
>>  I actually prefer the standard notebook because of its menus and buttons. 
>> My main problem is that my @interact examples that worked in Sage 6.XX (and
>> even the examples in the current  SageMath documentation) no longer work in

They don't work in sagenb at all in 7.4?  That would be a surprise.
 
>> the SageMath 7.4 standard notebook . Also, when I attempted to use the
>> Windows version of SageMath 7.4, it started up the Jupyter notebook instead
>> of the old notebook. Will these problems be fixed in future versions of

That was a decision by the distributor of the Windows/VirtualBox image.  You should be able to use the regular notebook with that by using notebook() from the Sage command line prompt.
 
Regarding what happened with the Sage distribution, nobody wanted to
maintain the old sage notebook, so people decided Sage should switch
to Jupyter, which is maintained and developed.    Other people then
tried to implement something like Sage's @interact on top of what
Jupyter provides, but they evidently didn't do so sufficiently
robustly yet...


But see https://trac.sagemath.org/ticket/21267 which apparently will deal with most of that. 
Reply all
Reply to author
Forward
0 new messages