syntax error and/or modes

82 views
Skip to first unread message

kcrisman

unread,
Oct 31, 2016, 9:42:11 PM10/31/16
to sage-cloud
I understood well how to use modes in sagenb, but here I'm at a loss.  Clicking on the %sage on the upper right just brings up a mysterious wizard, and doing this yields weird errors.  Is there a way to get the whole sheet to evaluate in Python (or R, or ...) in a .sagews (as opposed to Jupyter)?

%python
import numpy as np
Error in lines 1-1
Traceback (most recent call last):
  File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 968, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "<string>", line 1
    e = import numpy as np
             ^
SyntaxError: invalid syntax

William Stein

unread,
Oct 31, 2016, 9:48:41 PM10/31/16
to sage-cloud
On Mon, Oct 31, 2016 at 6:42 PM, kcrisman <kcri...@gmail.com> wrote:
> I understood well how to use modes in sagenb, but here I'm at a loss.
> Clicking on the %sage on the upper right just brings up a mysterious wizard,
> and doing this yields weird errors.

Your example works fine for me.

> Is there a way to get the whole sheet
> to evaluate in Python (or R, or ...) in a .sagews (as opposed to Jupyter)?

Click the very first menu on the left labeled modes...

>
> %python
> import numpy as np
>
> Error in lines 1-1
> Traceback (most recent call last):
> File
> "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/smc_sagews/sage_server.py",
> line 968, in execute
> exec compile(block+'\n', '', 'single') in namespace, locals
> File "<string>", line 1
> e = import numpy as np
> ^
> SyntaxError: invalid syntax
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-cloud" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-cloud+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cloud/fdec4685-c634-475a-9357-d25af57fef1b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--

Best Regards,
William Stein

CEO, SageMath, Inc.
Screen Shot 2016-10-31 at 6.46.53 PM.png
Screen Shot 2016-10-31 at 6.47.53 PM.png

kcrisman

unread,
Oct 31, 2016, 10:06:41 PM10/31/16
to sage-cloud
 

Your example works fine for me.

Huh.  Somehow got corrupted, maybe.
 
> Is there a way to get the whole sheet
> to evaluate in Python (or R, or ...) in a .sagews (as opposed to Jupyter)?

Click the very first menu on the left labeled modes...


Yes, I tried that, and it only inserted %python in my cell.  Using Safari 10.0 perhaps that is the problem?   In FF happens too.

Also, unrelated but weirdly stacked numbers on the left:

 

William Stein

unread,
Oct 31, 2016, 10:10:57 PM10/31/16
to sage-cloud
It seems like absolutely everything is broken for you.      As you can see in my screen shot, clicking the Modes menu should display a menu, not insert "%python".   Maybe you're using old versions of web browsers, or have browser plugins that interfere with SMC, or have things way zoomed in/out?  Definitely the menus work, etc. in Safari and Firefox -- I just checked; also thousands of people used Sage worksheets on SMC today without reporting any issues.

William
 

 

--
You received this message because you are subscribed to the Google Groups "sage-cloud" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-cloud+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cloud/295e9e5a-c8e4-4869-999f-4f97a20e8f1b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

kcrisman

unread,
Nov 1, 2016, 12:45:07 PM11/1/16
to sage-cloud


Also, unrelated but weirdly stacked numbers on the left:

It seems like absolutely everything is broken for you.      As you can see in my screen shot, clicking the Modes menu should display a menu, not insert "%python".   Maybe you're using old versions of web browsers, or have browser plugins that interfere with SMC, or have things way zoomed in/out? 

All I can say is that I reported this because it happened, not because I expected it.  I have not been doing anything unusual and am using up-to-date versions of browsers. I'll report again if I see it again, not anticipating that, though.   Maybe it's just punishment from the CSS gods for not using SMC enough? ;-) 

William Stein

unread,
Nov 1, 2016, 12:58:42 PM11/1/16
to sage-cloud
On Tue, Nov 1, 2016 at 9:45 AM, kcrisman <kcri...@gmail.com> wrote:
> I have not been doing anything unusual and am using up-to-date
> versions of browsers.

Not to be annoying, but Safari is at "Version 10.0.1" (at least for
me) and you say you're using "Version 10.0".

> I'll report again if I see it again, not anticipating that, though.

OK, so you're never going to use SMC again.

If anybody else sees similar problems and ends up here, what Karl
reported makes absolutely no sense, and is not at all the way SMC
works. He's reporting even the basic drop down menus not working at
all. If you do see similar problems, please click the help button in
the upper right and create a support request. It's also useful to
know:

- Do you have any browser extensions installed? Some will
significantly interfere with the javascript or html in the page and
completely break SMC. We have a troubleshooting entry about this
here:

https://github.com/sagemathinc/smc/wiki/Troubleshooting#step-5-have-you-installed-some-browser-extensions-sometimes-called-add-ons

- Is your browser zoom setting other than 100%? This can cause
trouble in some cases.

Also, Chrome is the most supported browser for using SageMathCloud and
is used by nearly 70% of people using SMC.

-- William

kcrisman

unread,
Nov 2, 2016, 1:05:28 PM11/2/16
to sage-cloud

 
> I have not been doing anything unusual and am using up-to-date
> versions of browsers.

Not to be annoying, but Safari is at "Version 10.0.1" (at least for
me) and you say you're using "Version 10.0".

That upgrade only came through after I reported this, or at least my system only reported it then.  I still see the %python behavior now with 10.0.1.
 

>  I'll report again if I see it again, not anticipating that, though.

OK, so you're never going to use SMC again.

No, I really think this was a once-off, since I had never seen it before (the weird #s).  I don't have anything unusual going on like you suggest e.g. plugins.

But there is something going wrong.  I have exactly the same behavior with FF 47.0.  It is now downloading updates ... restart to update ... now 49.0.2, still exactly same problems.  




 

Also, Chrome is the most supported browser for using SageMathCloud and
is used by nearly 70% of people using SMC.

But it would be nice for SMC not to require a specific browser - remember all those sites that "worked best with IE5"?  That was a barrel of laughs. (Though of course Chrome is far superior to IE5.  But still, product lock-in...)

Aaron Tresham

unread,
Nov 2, 2016, 1:49:02 PM11/2/16
to sage-cloud
Isn't selecting "Python" from the modes drop-down menu supposed to put %python in the cell? That's how you change the mode in SMC, right? (But I don't use many of these modes, so perhaps I have misunderstood.)

Aaron

kcrisman

unread,
Nov 2, 2016, 1:55:30 PM11/2/16
to sage-cloud


On Wednesday, November 2, 2016 at 1:49:02 PM UTC-4, Aaron Tresham wrote:
Isn't selecting "Python" from the modes drop-down menu supposed to put %python in the cell? That's how you change the mode in SMC, right? (But I don't use many of these modes, so perhaps I have misunderstood.)

That may be the case!  But in that case, I don't know how to change the *entire worksheet* to be plain Python. 

Harald Schilly

unread,
Nov 2, 2016, 1:59:02 PM11/2/16
to sage-cloud
On Wed, Nov 2, 2016 at 6:55 PM, kcrisman <kcri...@gmail.com> wrote:
> But in that case, I don't know how to change the *entire worksheet* to be
> plain Python.

Via that:

---
%default_mode python
---

and when you want that cell to be evaluated every time the process on
the server restarts:

---
%auto
%default_mode python
---

Besides that, I didn't really understand what this thread was about.
The only real odd thing I see is, that there is an additional newline
before the %python when it is inserted. %python should be in the first
line of the cell!

-- harald

kcrisman

unread,
Nov 3, 2016, 3:13:18 PM11/3/16
to sage-cloud



Via that:

---
%default_mode python
---

Thank you!  That was what I was asking in the first place, but apparently didn't convey that well.

That should somehow be a dropdown thing just like in sagenb, since one might imagine that (like in Jupyter?) one might often want to choose different systems for an entire sheet.

 
Besides that, I didn't really understand what this thread was about.
The only real odd thing I see is, that there is an additional newline
before the %python when it is inserted. %python should be in the first
line of the cell!


But wherever you are in the cell it inserts there.  I don't know if that is a bug or user error, but at any rate that is what happens, I think. 

William Stein

unread,
Nov 3, 2016, 3:24:44 PM11/3/16
to sage-cloud
On Thu, Nov 3, 2016 at 12:13 PM, kcrisman <kcri...@gmail.com> wrote:
>
>
>>
>> Via that:
>>
>> ---
>> %default_mode python
>> ---
>>
> Thank you! That was what I was asking in the first place, but apparently
> didn't convey that well.
>
> That should somehow be a dropdown thing just like in sagenb, since one might
> imagine that (like in Jupyter?) one might often want to choose different
> systems for an entire sheet.

It is in a dropdown menu. Of course we do want to improve those
menus, e.g., have a submenu for each mode or some other way to easily
know the available modes.

However, a difference between SageMathCloud worksheets and
sagenb/Jupyter is that everything is explicit. There is no hidden
implicit state only accessible via menus, like in sagenb and jupyter.
The only possible way to make the mode for the whole worksheet be
python is to explicitly use "%default_mode python".

>> Besides that, I didn't really understand what this thread was about.
>> The only real odd thing I see is, that there is an additional newline
>> before the %python when it is inserted. %python should be in the first
>> line of the cell!
>>
>
> But wherever you are in the cell it inserts there. I don't know if that is
> a bug or user error, but at any rate that is what happens, I think.

Things will work fine even if it there is a blank line before %python.

William

kcrisman

unread,
Nov 4, 2016, 12:51:46 PM11/4/16
to sage-cloud

It is in a dropdown menu.   Of course we do want to improve those
menus, e.g., have a submenu for each mode or some other way to easily
know the available modes.


Which one?  I still can't find it.  I do not see an option for the %default_mode python in the dropdown menu for modes.  For that matter, going to the help menu and clicking on mode commands doesn't seem to do anything either, though perhaps I am using it incorrectly.

Honestly, I think that a great place for default mode change would be the thing on the far upper left that usually says "%sage".  But I couldn't figure out how to change that to anything else; clicking on it just brings up the wizard.


 
However, a difference between SageMathCloud worksheets and
sagenb/Jupyter is that everything is explicit.  There is no hidden
implicit state only accessible via menus, like in sagenb and jupyter.

That seems quite reasonable. 

William Stein

unread,
Nov 4, 2016, 12:56:38 PM11/4/16
to sage-cloud
On Fri, Nov 4, 2016 at 9:51 AM, kcrisman <kcri...@gmail.com> wrote:
>
>> It is in a dropdown menu. Of course we do want to improve those
>> menus, e.g., have a submenu for each mode or some other way to easily
>> know the available modes.
>>
>
> Which one? I still can't find it. I do not see an option for the
> %default_mode python in the dropdown menu for modes.

"Set default mode" is the third item in the menu. I don't know why
you can't see it. I've attached a screenshot so you can see what the
menu looks like when properly rendered, so you can compare to what you
are seeing.

> For that matter, going
> to the help menu and clicking on mode commands doesn't seem to do anything
> either, though perhaps I am using it incorrectly.

Going to the help menu and clicking will insert code where the cursor
is positioned.

> Honestly, I think that a great place for default mode change would be the
> thing on the far upper left that usually says "%sage". But I couldn't
> figure out how to change that to anything else; clicking on it just brings
> up the wizard.

Clicking on that brings up the wizard -- it's meant to be an "easter
egg". The wizard should be moved to a normal dropdown menu (or new
normal button). Clicking on the mode indicator should either do
*nothing*, or provide some help about modes (e.g., a dialog with a
link to the wiki).

>
>
>
>>
>> However, a difference between SageMathCloud worksheets and
>> sagenb/Jupyter is that everything is explicit. There is no hidden
>> implicit state only accessible via menus, like in sagenb and jupyter.
>
>
> That seems quite reasonable.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-cloud" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-cloud+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cloud/1d2c64bc-5b69-4e2c-9808-6a6a98068600%40googlegroups.com.
Screen Shot 2016-11-04 at 9.52.43 AM.png

kcrisman

unread,
Nov 5, 2016, 12:45:05 PM11/5/16
to sage-cloud

>
>> It is in a dropdown menu.   Of course we do want to improve those
>> menus, e.g., have a submenu for each mode or some other way to easily
>> know the available modes.
>>
>
> Which one?  I still can't find it.  I do not see an option for the
> %default_mode python in the dropdown menu for modes.

"Set default mode" is the third item in the menu.   I don't know why
you can't see it.  I've attached a screenshot so you can see what the
menu looks like when properly rendered, so you can compare to what you
are seeing.

Now I know what you are talking about.  I was looking for something specifically "python" - I also now understand what you meant by submenus!  Yes, that would be very helpful. 
Reply all
Reply to author
Forward
0 new messages