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.Wed, 21 Mar 2012 20:16:17 +0100Script stops working when imported to sage terminal ("plot" not defined)https://ask.sagemath.org/question/8811/script-stops-working-when-imported-to-sage-terminal-plot-not-defined/**EDIT:** OK, so basically, the Sage command line is not recognizing *any* sage commands (sqrt, etc) when they are contained in an imported .sage file. It's as if when I import a file to Sage, it doesn't read it using the Sage library. Is there something I have to add to the header of a .sage file for it to be read properly?
***
**Old message:**
So everything works fine in the sage notebook, and even if I pretty much rewrite the same commands in the Sage terminal. So it can't be a problem with the script.
But when I copy, paste and save the whole script as a standalone `file.sage`, and then try
run file.sage
... suddenly:
---> 30 multiPlot = plot(graphs, (x, 0, times[len(times)-1]+3), ymin=0)
31
32
NameError: name 'plot' is not defined
Why doesn't it read "plot" correctly and expect me to define it?Wed, 21 Mar 2012 18:46:24 +0100https://ask.sagemath.org/question/8811/script-stops-working-when-imported-to-sage-terminal-plot-not-defined/Answer by Shashank for <p><strong>EDIT:</strong> OK, so basically, the Sage command line is not recognizing <em>any</em> sage commands (sqrt, etc) when they are contained in an imported .sage file. It's as if when I import a file to Sage, it doesn't read it using the Sage library. Is there something I have to add to the header of a .sage file for it to be read properly?</p>
<hr/>
<p><strong>Old message:</strong></p>
<p>So everything works fine in the sage notebook, and even if I pretty much rewrite the same commands in the Sage terminal. So it can't be a problem with the script. </p>
<p>But when I copy, paste and save the whole script as a standalone <code>file.sage</code>, and then try</p>
<pre><code>run file.sage
</code></pre>
<p>... suddenly:</p>
<pre><code>---> 30 multiPlot = plot(graphs, (x, 0, times[len(times)-1]+3), ymin=0)
31
32
NameError: name 'plot' is not defined
</code></pre>
<p>Why doesn't it read "plot" correctly and expect me to define it?</p>
https://ask.sagemath.org/question/8811/script-stops-working-when-imported-to-sage-terminal-plot-not-defined/?answer=13385#post-id-13385use
run -i file.sage
that should workWed, 21 Mar 2012 19:21:41 +0100https://ask.sagemath.org/question/8811/script-stops-working-when-imported-to-sage-terminal-plot-not-defined/?answer=13385#post-id-13385Comment by fakaff for <p>use</p>
<pre><code>run -i file.sage
</code></pre>
<p>that should work</p>
https://ask.sagemath.org/question/8811/script-stops-working-when-imported-to-sage-terminal-plot-not-defined/?comment=20093#post-id-20093Now it's giving me error for using `^` instead of `**`. It seems to be completely ignoring the fact that it's sage code, not 100% python... even though I am inside the sage command line thingy and the exact same script works perfectly if I just copy in paste it.Wed, 21 Mar 2012 19:47:36 +0100https://ask.sagemath.org/question/8811/script-stops-working-when-imported-to-sage-terminal-plot-not-defined/?comment=20093#post-id-20093Comment by fakaff for <p>use</p>
<pre><code>run -i file.sage
</code></pre>
<p>that should work</p>
https://ask.sagemath.org/question/8811/script-stops-working-when-imported-to-sage-terminal-plot-not-defined/?comment=20091#post-id-20091That works here too. -- no reason in particular, just bugging me that it doesn't work and I might need it in the future. Wed, 21 Mar 2012 20:16:17 +0100https://ask.sagemath.org/question/8811/script-stops-working-when-imported-to-sage-terminal-plot-not-defined/?comment=20091#post-id-20091Comment by Shashank for <p>use</p>
<pre><code>run -i file.sage
</code></pre>
<p>that should work</p>
https://ask.sagemath.org/question/8811/script-stops-working-when-imported-to-sage-terminal-plot-not-defined/?comment=20092#post-id-20092Yeah I am getting the same problem. I normally don't use run command. Instead I just type sage file.sage. That way you don't face that problem. Is there some reason you want to use run instead of sage file.sage?Wed, 21 Mar 2012 20:03:22 +0100https://ask.sagemath.org/question/8811/script-stops-working-when-imported-to-sage-terminal-plot-not-defined/?comment=20092#post-id-20092