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.Tue, 28 Apr 2020 12:21:55 +0200Plot not workinghttps://ask.sagemath.org/question/51044/plot-not-working/I am new to SageMath and am following the examples from the basic tutorials. The following command does not work:
> plot3d(x^2 + y^2, (x,-2,2), (y,-2,2))
The error message is
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0:`sage-open/Users/xxx/.sage/temp/MacBook-Pro-(6)/1333/tmp_smrlkile.html 2>/dev/null 1>/dev/null &'
Browsing to the temp directory, I do find the .html file and can open it (it displays the right graph). It seems the viewer cannot open it from the terminal application of SageMath. Is this due to the presence of parentheses in the auto-generated temporary directory? If so, how can I changed it?Sun, 26 Apr 2020 17:37:16 +0200https://ask.sagemath.org/question/51044/plot-not-working/Comment by slelievre for <p>I am new to SageMath and am following the examples from the basic tutorials. The following command does not work:</p>
<blockquote>
<p>plot3d(x^2 + y^2, (x,-2,2), (y,-2,2))</p>
</blockquote>
<p>The error message is</p>
<pre><code>sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0:`sage-open/Users/xxx/.sage/temp/MacBook-Pro-(6)/1333/tmp_smrlkile.html 2>/dev/null 1>/dev/null &'
</code></pre>
<p>Browsing to the temp directory, I do find the .html file and can open it (it displays the right graph). It seems the viewer cannot open it from the terminal application of SageMath. Is this due to the presence of parentheses in the auto-generated temporary directory? If so, how can I changed it?</p>
https://ask.sagemath.org/question/51044/plot-not-working/?comment=51060#post-id-51060Welcome to Ask Sage! Thank you for your question!Mon, 27 Apr 2020 15:40:31 +0200https://ask.sagemath.org/question/51044/plot-not-working/?comment=51060#post-id-51060Comment by slelievre for <p>I am new to SageMath and am following the examples from the basic tutorials. The following command does not work:</p>
<blockquote>
<p>plot3d(x^2 + y^2, (x,-2,2), (y,-2,2))</p>
</blockquote>
<p>The error message is</p>
<pre><code>sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0:`sage-open/Users/xxx/.sage/temp/MacBook-Pro-(6)/1333/tmp_smrlkile.html 2>/dev/null 1>/dev/null &'
</code></pre>
<p>Browsing to the temp directory, I do find the .html file and can open it (it displays the right graph). It seems the viewer cannot open it from the terminal application of SageMath. Is this due to the presence of parentheses in the auto-generated temporary directory? If so, how can I changed it?</p>
https://ask.sagemath.org/question/51044/plot-not-working/?comment=51061#post-id-51061The operating system seems to be macOS, but what version of macOS? What version of Sage? How was it installed: via Conda, via Homebrew, from a binary downloaded from the SageMath website, or built from source? Are you using Sage in the terminal, in a Jupyter notebook, or in any other way?Mon, 27 Apr 2020 15:42:39 +0200https://ask.sagemath.org/question/51044/plot-not-working/?comment=51061#post-id-51061Answer by Sébastien for <p>I am new to SageMath and am following the examples from the basic tutorials. The following command does not work:</p>
<blockquote>
<p>plot3d(x^2 + y^2, (x,-2,2), (y,-2,2))</p>
</blockquote>
<p>The error message is</p>
<pre><code>sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0:`sage-open/Users/xxx/.sage/temp/MacBook-Pro-(6)/1333/tmp_smrlkile.html 2>/dev/null 1>/dev/null &'
</code></pre>
<p>Browsing to the temp directory, I do find the .html file and can open it (it displays the right graph). It seems the viewer cannot open it from the terminal application of SageMath. Is this due to the presence of parentheses in the auto-generated temporary directory? If so, how can I changed it?</p>
https://ask.sagemath.org/question/51044/plot-not-working/?answer=51059#post-id-51059I think it does not like the fact that your computer is called `MacBook-Pro-(6)` where some characters are parenthesis. In SageMath, the name of the computer (hostname) is used to construct the path of a temporary file:
sage: tmp_filename(ext='.html')
'/home/USERNAME/.sage/temp/HOSTNAME/28099/tmp_9_rl571y.html'
The error occurs when it tries to open that filename which contains parenthesis. If you can change the HOSTNAME by removing the parenthesis, it should fix the issue. Also, I don't know, maybe this is a bug that could be fixed in the SageMath library.
Trying to find a workaround does not seem easy as I am not able to save the graphics to the local folder which would not contain parenthesis in your case:
sage: y=var('y'); G = plot3d(x^2 + y^2, (x,-2,2), (y,-2,2))
sage: G.save('a.html')
Traceback (most recent call last):
...
ValueError: filetype .html not supported by save()Mon, 27 Apr 2020 15:31:43 +0200https://ask.sagemath.org/question/51044/plot-not-working/?answer=51059#post-id-51059Comment by slelievre for <p>I think it does not like the fact that your computer is called <code>MacBook-Pro-(6)</code> where some characters are parenthesis. In SageMath, the name of the computer (hostname) is used to construct the path of a temporary file:</p>
<pre><code>sage: tmp_filename(ext='.html')
'/home/USERNAME/.sage/temp/HOSTNAME/28099/tmp_9_rl571y.html'
</code></pre>
<p>The error occurs when it tries to open that filename which contains parenthesis. If you can change the HOSTNAME by removing the parenthesis, it should fix the issue. Also, I don't know, maybe this is a bug that could be fixed in the SageMath library.</p>
<p>Trying to find a workaround does not seem easy as I am not able to save the graphics to the local folder which would not contain parenthesis in your case:</p>
<pre><code>sage: y=var('y'); G = plot3d(x^2 + y^2, (x,-2,2), (y,-2,2))
sage: G.save('a.html')
Traceback (most recent call last):
...
ValueError: filetype .html not supported by save()
</code></pre>
https://ask.sagemath.org/question/51044/plot-not-working/?comment=51062#post-id-51062Excellent analysis.
In that case, before launching Sage, change the hostname.
So depending on whether you want to use the REPL, or Jupyter Notebook, or Jupyter Lab:
HOSTNAME=MacBookPro sage
HOSTNAME=MacBookPro sage -n jupyter
HOSTNAME=MacBookPro sage -n jupyterlab
To fix more permanently, either set the HOSTNAME to something without parentheses
in `~/.bash_profile` or `~/.zsh_profile`, or define an alias there such as
alias sage="HOSTNAME=MacBookPro sage"Mon, 27 Apr 2020 15:51:01 +0200https://ask.sagemath.org/question/51044/plot-not-working/?comment=51062#post-id-51062Comment by ZeJibe for <p>I think it does not like the fact that your computer is called <code>MacBook-Pro-(6)</code> where some characters are parenthesis. In SageMath, the name of the computer (hostname) is used to construct the path of a temporary file:</p>
<pre><code>sage: tmp_filename(ext='.html')
'/home/USERNAME/.sage/temp/HOSTNAME/28099/tmp_9_rl571y.html'
</code></pre>
<p>The error occurs when it tries to open that filename which contains parenthesis. If you can change the HOSTNAME by removing the parenthesis, it should fix the issue. Also, I don't know, maybe this is a bug that could be fixed in the SageMath library.</p>
<p>Trying to find a workaround does not seem easy as I am not able to save the graphics to the local folder which would not contain parenthesis in your case:</p>
<pre><code>sage: y=var('y'); G = plot3d(x^2 + y^2, (x,-2,2), (y,-2,2))
sage: G.save('a.html')
Traceback (most recent call last):
...
ValueError: filetype .html not supported by save()
</code></pre>
https://ask.sagemath.org/question/51044/plot-not-working/?comment=51094#post-id-51094Thanks a ton - this works indeed!Tue, 28 Apr 2020 12:21:55 +0200https://ask.sagemath.org/question/51044/plot-not-working/?comment=51094#post-id-51094