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, 19 Aug 2016 02:17:21 +0200Interact in standalone SageMath do not work as SageMathCellhttps://ask.sagemath.org/question/34504/interact-in-standalone-sagemath-do-not-work-as-sagemathcell/I downloaded SageMath VM for Windows from sagemath <br>
If I try an interact example:
>@interact<br>
>def _(n=slider(1,20, step_size=1)):<br>
> print(factorial(n))
it does not work unless I do first:
> from
> sagenb.notebook.interact import *
what is nowhere in the documentation by the way. Even so, I need to call the function first (what in SageMathCell is not needed):
> _()
I get the error:
> TypeError
> Traceback (most recent call last)
> <ipython-input-65-02a00410cc9d> in
> <module>()
> ----> 1 _()
>
> <ipython-input-64-067de41a741b> in
> _(n)
> 1 @interact
> 2 def _(n=slider(Integer(1),Integer(20), step_size=Integer(1))):
> ----> 3 print(factorial(n))
>
> /home/sage/sage-7.2/src/sage/symbolic/function.pyx
> in
> sage.symbolic.function.GinacFunction.__call__
> (/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:9536)()
> 819 (0, Integer Ring)
> 820 """
> --> 821 res = super(GinacFunction,
> self).__call__(*args, **kwds)
> 822
> 823 # Convert to Integer if the output was of type "int" and
> any of
>
> /home/sage/sage-7.2/src/sage/symbolic/function.pyx
> in
> sage.symbolic.function.BuiltinFunction.__call__
> (/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:11161)()
> 970 res = self._evalf_try_(*args)
> 971 if res is None:
> --> 972 res = super(BuiltinFunction, self).__call__(
> 973 *args, coerce=coerce, hold=hold)
> 974
>
> /home/sage/sage-7.2/src/sage/symbolic/function.pyx
> in
> sage.symbolic.function.Function.__call__
> (/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:6754)()
> 469 if callable(method):
> 470 return method()
> --> 471 raise TypeError("cannot coerce arguments:
> %s" % (err))
> 472
> 473 else: # coerce == False
>
> TypeError: cannot coerce arguments: no
> canonical coercion from <type
> 'instance'> to Symbolic Ring
But in SageMathCell it works.
If I change print(factorial(n)) for print(type(n)) when I call _() I get:
> <type 'instance'>
Again If I just call print(n) I get:
> Slider: None [1--|1|---20]
I understand that this means that n (the slider) is not a number. But again in SageMathCell it works.
UPDATE:
I am using Sage-7.2-ova virtual machine image for Windows (a dedicated CentOS machine) (unfortunately I have no karma to post links) in a Windows 10 VM under VMware Workstation 12. Player.
The machine has an integrated Chromium browser, the VM is completely off the shelf, just open the OVA and the machine is running. The only configs I did were:
* for the keyboard (ABNT2 BR);
* to access the web server from the host;
* to install VMWare tools and get a shared folder with the host
but the error was there before all that.
And the error is not about the browser, the interpreter obviously do not accept the commands, the stack trace is very consistent about that, as the SageMathCell site (no links again because of my karma) was a different version (at least on the interact package).
IMPORTANT:
I am not using sage on command line. I am using on Sage Notebook on Jupyter via browser (not using aPython kernel, but Sage 7.2 kernel), by clicking New Notebook.
On command the line I have the exact same behavior.Wed, 17 Aug 2016 21:38:47 +0200https://ask.sagemath.org/question/34504/interact-in-standalone-sagemath-do-not-work-as-sagemathcell/Comment by kcrisman for <div class="snippet"><p>I downloaded SageMath VM for Windows from sagemath <br>
If I try an interact example:</p>
<blockquote>
<p>@interact<br>
def _(n=slider(1,20, step_size=1)):<br>
print(factorial(n))</p>
</blockquote>
<p>it does not work unless I do first:</p>
<blockquote>
<p> from
sagenb.notebook.interact import *</p>
</blockquote>
<p>what is nowhere in the documentation by the way. Even so, I need to call the function first (what in SageMathCell is not needed):</p>
<blockquote>
<p> _()</p>
</blockquote>
<p>I get the error:</p>
<blockquote>
<p>TypeError <br>
Traceback (most recent call last)
<ipython-input-65-02a00410cc9d> in
<module>()
----> 1 _()</p>
<p><ipython-input-64-067de41a741b> in
_(n)
1 @interact
2 def _(n=slider(Integer(1),Integer(20), step_size=Integer(1))):
----> 3 print(factorial(n))</p>
<p>/home/sage/sage-7.2/src/sage/symbolic/function.pyx
in
sage.symbolic.function.GinacFunction.__call__
(/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:9536)()
819 (0, Integer Ring)
820 """
--> 821 res = super(GinacFunction,
self).__call__(<em>args, *</em>kwds)
822
823 # Convert to Integer if the output was of type "int" and
any of</p>
<p>/home/sage/sage-7.2/src/sage/symbolic/function.pyx
in
sage.symbolic.function.BuiltinFunction.__call__
(/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:11161)()
970 res = self._evalf_try_(*args)
971 if res is None:
--> 972 res = super(BuiltinFunction, self).__call__(
973 *args, coerce=coerce, hold=hold)
974 </p>
<p>/home/sage/sage-7.2/src/sage/symbolic/function.pyx
in
sage.symbolic.function.Function.__call__
(/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:6754)()
469 if callable(method):
470 return method()
--> 471 raise TypeError("cannot coerce arguments:
%s" % (err))
472
473 else: # coerce == False</p>
<p>TypeError: cannot coerce arguments: no
canonical coercion from <type 'instance'=""> to Symbolic Ring</p>
</blockquote>
<p>But in SageMathCell it works.</p>
<p>If I change print(factorial(n)) for print(type(n)) when I call _() I get:</p>
<blockquote>
<p> <type 'instance'></p>
</blockquote>
<p>Again If I just call print(n) I get:</p>
<blockquote>
<p> Slider: None [1--|1|---20]</p>
</blockquote>
<p>I understand that this means that n (the slider) is not a number. But again in SageMathCell it works.</p>
<p>UPDATE: </p>
<p>I am using Sage-7.2-ova virtual machine image for Windows (a dedicated CentOS machine) (unfortunately I have no karma to post links) in a Windows 10 VM under VMware Workstation 12. Player. </p>
<p>The machine has an integrated Chromium browser, the VM is completely off the shelf, just open the OVA and the machine is running. The only configs I did were:
* for the keyboard (ABNT2 BR);
* to access the web server from the host;
* to install VMWare tools and get a shared folder with the host</p>
<p>but the error was there before all that.</p>
<p>And the error is not about the browser, the interpreter obviously do not accept the commands, the stack trace is very consistent about that, as the SageMathCell site (no links again because of my karma) was a different version (at least on the interact package).</p>
<p>IMPORTANT: </p>
<p>I am not using sage on command line. I am using on Sage Notebook on Jupyter via browser (not using aPython kernel, but Sage 7.2 kernel), by clicking New Notebook.</p>
<p>On command the line I have ...<span class="expander"> <a>(more)</a></span></p></div>https://ask.sagemath.org/question/34504/interact-in-standalone-sagemath-do-not-work-as-sagemathcell/?comment=34516#post-id-34516This works for me in the sagenb in 7.3.beta7. Can you give a little more information about your setup (e.g. which version of Sage you are using, which browser)? This does seem odd, as it is fairly standard. You definitely shouldn't have to import anything to use it!Thu, 18 Aug 2016 15:18:40 +0200https://ask.sagemath.org/question/34504/interact-in-standalone-sagemath-do-not-work-as-sagemathcell/?comment=34516#post-id-34516Comment by Airton Granero for <div class="snippet"><p>I downloaded SageMath VM for Windows from sagemath <br>
If I try an interact example:</p>
<blockquote>
<p>@interact<br>
def _(n=slider(1,20, step_size=1)):<br>
print(factorial(n))</p>
</blockquote>
<p>it does not work unless I do first:</p>
<blockquote>
<p> from
sagenb.notebook.interact import *</p>
</blockquote>
<p>what is nowhere in the documentation by the way. Even so, I need to call the function first (what in SageMathCell is not needed):</p>
<blockquote>
<p> _()</p>
</blockquote>
<p>I get the error:</p>
<blockquote>
<p>TypeError <br>
Traceback (most recent call last)
<ipython-input-65-02a00410cc9d> in
<module>()
----> 1 _()</p>
<p><ipython-input-64-067de41a741b> in
_(n)
1 @interact
2 def _(n=slider(Integer(1),Integer(20), step_size=Integer(1))):
----> 3 print(factorial(n))</p>
<p>/home/sage/sage-7.2/src/sage/symbolic/function.pyx
in
sage.symbolic.function.GinacFunction.__call__
(/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:9536)()
819 (0, Integer Ring)
820 """
--> 821 res = super(GinacFunction,
self).__call__(<em>args, *</em>kwds)
822
823 # Convert to Integer if the output was of type "int" and
any of</p>
<p>/home/sage/sage-7.2/src/sage/symbolic/function.pyx
in
sage.symbolic.function.BuiltinFunction.__call__
(/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:11161)()
970 res = self._evalf_try_(*args)
971 if res is None:
--> 972 res = super(BuiltinFunction, self).__call__(
973 *args, coerce=coerce, hold=hold)
974 </p>
<p>/home/sage/sage-7.2/src/sage/symbolic/function.pyx
in
sage.symbolic.function.Function.__call__
(/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:6754)()
469 if callable(method):
470 return method()
--> 471 raise TypeError("cannot coerce arguments:
%s" % (err))
472
473 else: # coerce == False</p>
<p>TypeError: cannot coerce arguments: no
canonical coercion from <type 'instance'=""> to Symbolic Ring</p>
</blockquote>
<p>But in SageMathCell it works.</p>
<p>If I change print(factorial(n)) for print(type(n)) when I call _() I get:</p>
<blockquote>
<p> <type 'instance'></p>
</blockquote>
<p>Again If I just call print(n) I get:</p>
<blockquote>
<p> Slider: None [1--|1|---20]</p>
</blockquote>
<p>I understand that this means that n (the slider) is not a number. But again in SageMathCell it works.</p>
<p>UPDATE: </p>
<p>I am using Sage-7.2-ova virtual machine image for Windows (a dedicated CentOS machine) (unfortunately I have no karma to post links) in a Windows 10 VM under VMware Workstation 12. Player. </p>
<p>The machine has an integrated Chromium browser, the VM is completely off the shelf, just open the OVA and the machine is running. The only configs I did were:
* for the keyboard (ABNT2 BR);
* to access the web server from the host;
* to install VMWare tools and get a shared folder with the host</p>
<p>but the error was there before all that.</p>
<p>And the error is not about the browser, the interpreter obviously do not accept the commands, the stack trace is very consistent about that, as the SageMathCell site (no links again because of my karma) was a different version (at least on the interact package).</p>
<p>IMPORTANT: </p>
<p>I am not using sage on command line. I am using on Sage Notebook on Jupyter via browser (not using aPython kernel, but Sage 7.2 kernel), by clicking New Notebook.</p>
<p>On command the line I have ...<span class="expander"> <a>(more)</a></span></p></div>https://ask.sagemath.org/question/34504/interact-in-standalone-sagemath-do-not-work-as-sagemathcell/?comment=34524#post-id-34524I had posted an update about that.Thu, 18 Aug 2016 22:28:15 +0200https://ask.sagemath.org/question/34504/interact-in-standalone-sagemath-do-not-work-as-sagemathcell/?comment=34524#post-id-34524Answer by Airton Granero for <div class="snippet"><p>I downloaded SageMath VM for Windows from sagemath <br>
If I try an interact example:</p>
<blockquote>
<p>@interact<br>
def _(n=slider(1,20, step_size=1)):<br>
print(factorial(n))</p>
</blockquote>
<p>it does not work unless I do first:</p>
<blockquote>
<p> from
sagenb.notebook.interact import *</p>
</blockquote>
<p>what is nowhere in the documentation by the way. Even so, I need to call the function first (what in SageMathCell is not needed):</p>
<blockquote>
<p> _()</p>
</blockquote>
<p>I get the error:</p>
<blockquote>
<p>TypeError <br>
Traceback (most recent call last)
<ipython-input-65-02a00410cc9d> in
<module>()
----> 1 _()</p>
<p><ipython-input-64-067de41a741b> in
_(n)
1 @interact
2 def _(n=slider(Integer(1),Integer(20), step_size=Integer(1))):
----> 3 print(factorial(n))</p>
<p>/home/sage/sage-7.2/src/sage/symbolic/function.pyx
in
sage.symbolic.function.GinacFunction.__call__
(/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:9536)()
819 (0, Integer Ring)
820 """
--> 821 res = super(GinacFunction,
self).__call__(<em>args, *</em>kwds)
822
823 # Convert to Integer if the output was of type "int" and
any of</p>
<p>/home/sage/sage-7.2/src/sage/symbolic/function.pyx
in
sage.symbolic.function.BuiltinFunction.__call__
(/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:11161)()
970 res = self._evalf_try_(*args)
971 if res is None:
--> 972 res = super(BuiltinFunction, self).__call__(
973 *args, coerce=coerce, hold=hold)
974 </p>
<p>/home/sage/sage-7.2/src/sage/symbolic/function.pyx
in
sage.symbolic.function.Function.__call__
(/home/sage/sage-7.2/src/build/cythonized/sage/symbolic/function.cpp:6754)()
469 if callable(method):
470 return method()
--> 471 raise TypeError("cannot coerce arguments:
%s" % (err))
472
473 else: # coerce == False</p>
<p>TypeError: cannot coerce arguments: no
canonical coercion from <type 'instance'=""> to Symbolic Ring</p>
</blockquote>
<p>But in SageMathCell it works.</p>
<p>If I change print(factorial(n)) for print(type(n)) when I call _() I get:</p>
<blockquote>
<p> <type 'instance'></p>
</blockquote>
<p>Again If I just call print(n) I get:</p>
<blockquote>
<p> Slider: None [1--|1|---20]</p>
</blockquote>
<p>I understand that this means that n (the slider) is not a number. But again in SageMathCell it works.</p>
<p>UPDATE: </p>
<p>I am using Sage-7.2-ova virtual machine image for Windows (a dedicated CentOS machine) (unfortunately I have no karma to post links) in a Windows 10 VM under VMware Workstation 12. Player. </p>
<p>The machine has an integrated Chromium browser, the VM is completely off the shelf, just open the OVA and the machine is running. The only configs I did were:
* for the keyboard (ABNT2 BR);
* to access the web server from the host;
* to install VMWare tools and get a shared folder with the host</p>
<p>but the error was there before all that.</p>
<p>And the error is not about the browser, the interpreter obviously do not accept the commands, the stack trace is very consistent about that, as the SageMathCell site (no links again because of my karma) was a different version (at least on the interact package).</p>
<p>IMPORTANT: </p>
<p>I am not using sage on command line. I am using on Sage Notebook on Jupyter via browser (not using aPython kernel, but Sage 7.2 kernel), by clicking New Notebook.</p>
<p>On command the line I have ...<span class="expander"> <a>(more)</a></span></p></div> https://ask.sagemath.org/question/34504/interact-in-standalone-sagemath-do-not-work-as-sagemathcell/?answer=34525#post-id-34525If on the command line I call
sage
and inside sage command line I do:
notebook()
another web interface is opened on localhost:8080/admin/1 (Sage notebook) instead of localhost:8000/tree# (Jupyter notebook), now I have and in this web interface it works.
The default home page on this VM is the Jupyter Notebook and in this one it does not work, but on sage notbook it works.
But it only works locally, on the host machine this interface is inaccessible even if you publish the worksheet, that will put it at ipaddress:8080/home/pub/0 (on the local machine it works as localhost:8080/home/pub/0).Thu, 18 Aug 2016 23:04:14 +0200https://ask.sagemath.org/question/34504/interact-in-standalone-sagemath-do-not-work-as-sagemathcell/?answer=34525#post-id-34525Comment by kcrisman for <p>If on the command line I call</p>
<pre><code> sage
</code></pre>
<p>and inside sage command line I do: </p>
<pre><code> notebook()
</code></pre>
<p>another web interface is opened on localhost:8080/admin/1 (Sage notebook) instead of localhost:8000/tree# (Jupyter notebook), now I have and in this web interface it works.</p>
<p>The default home page on this VM is the Jupyter Notebook and in this one it does not work, but on sage notbook it works.</p>
<p>But it only works locally, on the host machine this interface is inaccessible even if you publish the worksheet, that will put it at ipaddress:8080/home/pub/0 (on the local machine it works as localhost:8080/home/pub/0).</p>
https://ask.sagemath.org/question/34504/interact-in-standalone-sagemath-do-not-work-as-sagemathcell/?comment=34527#post-id-34527Correct, the Jupyter notebook does NOT have interacts that work in the same way as the Sage notebook or Sage cell server. This is a problem, and is a good reason for the Jupyter notebook not to be the default in the virtual machine, but the VM image is made in a slightly different way than the other binaries to be set up to do this. There are some interactive capabilities in it but I am not very familiar with them.Fri, 19 Aug 2016 02:17:21 +0200https://ask.sagemath.org/question/34504/interact-in-standalone-sagemath-do-not-work-as-sagemathcell/?comment=34527#post-id-34527