ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 15 Oct 2012 10:19:42 -0500python/sage scriptshttps://ask.sagemath.org/question/9407/pythonsage-scripts/First of all, my apologies for being a noob and a windows user. I'm using sage in virtualbox. I'm at this part of the tutorial: sagenb.org/doc/live/tutorial/programming.html#standalone-python-sage-scripts
I'm having 2 problems:
(1) I can't execute "./factor 2006". It says "no such file or directory", but the file is definitely there, and "sage -python factor 2006" works.
(2) factoring polynomials doesn't seem to work for me in sage. If I call factor on a string I get a TypeError: "unable to factor n".
**Edit**: Part of the problem may have been that the script was in a shared folder in VirtualBox. Here is some exact input/output, working completely locally (this changes the error in (2)).
`>./factor 2006`
`/usr/bin/env: sage -python: No such file or directory`
`>sage -python factor "32*x^5-1"`
`NameError: name 'x' is not defined`
Any assistance is much appreciated!Tue, 09 Oct 2012 09:52:29 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/Comment by kcrisman for <p>First of all, my apologies for being a noob and a windows user. I'm using sage in virtualbox. I'm at this part of the tutorial: sagenb.org/doc/live/tutorial/programming.html#standalone-python-sage-scripts</p>
<p>I'm having 2 problems:</p>
<p>(1) I can't execute "./factor 2006". It says "no such file or directory", but the file is definitely there, and "sage -python factor 2006" works.</p>
<p>(2) factoring polynomials doesn't seem to work for me in sage. If I call factor on a string I get a TypeError: "unable to factor n".</p>
<p><strong>Edit</strong>: Part of the problem may have been that the script was in a shared folder in VirtualBox. Here is some exact input/output, working completely locally (this changes the error in (2)).</p>
<p><code>>./factor 2006</code></p>
<p><code>/usr/bin/env: sage -python: No such file or directory</code></p>
<p><code>>sage -python factor "32*x^5-1"</code></p>
<p><code>NameError: name 'x' is not defined</code></p>
<p>Any assistance is much appreciated!</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18914#post-id-18914Hi! I can guess what your problems are, but it would be better if you posted *exact commands* that you tried that didn't work. That makes it easier for others to be helped by your question too!Tue, 09 Oct 2012 10:37:33 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18914#post-id-18914Comment by rmp251 for <p>First of all, my apologies for being a noob and a windows user. I'm using sage in virtualbox. I'm at this part of the tutorial: sagenb.org/doc/live/tutorial/programming.html#standalone-python-sage-scripts</p>
<p>I'm having 2 problems:</p>
<p>(1) I can't execute "./factor 2006". It says "no such file or directory", but the file is definitely there, and "sage -python factor 2006" works.</p>
<p>(2) factoring polynomials doesn't seem to work for me in sage. If I call factor on a string I get a TypeError: "unable to factor n".</p>
<p><strong>Edit</strong>: Part of the problem may have been that the script was in a shared folder in VirtualBox. Here is some exact input/output, working completely locally (this changes the error in (2)).</p>
<p><code>>./factor 2006</code></p>
<p><code>/usr/bin/env: sage -python: No such file or directory</code></p>
<p><code>>sage -python factor "32*x^5-1"</code></p>
<p><code>NameError: name 'x' is not defined</code></p>
<p>Any assistance is much appreciated!</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18910#post-id-18910See my edit, thanks.Tue, 09 Oct 2012 16:48:49 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18910#post-id-18910Comment by kcrisman for <p>First of all, my apologies for being a noob and a windows user. I'm using sage in virtualbox. I'm at this part of the tutorial: sagenb.org/doc/live/tutorial/programming.html#standalone-python-sage-scripts</p>
<p>I'm having 2 problems:</p>
<p>(1) I can't execute "./factor 2006". It says "no such file or directory", but the file is definitely there, and "sage -python factor 2006" works.</p>
<p>(2) factoring polynomials doesn't seem to work for me in sage. If I call factor on a string I get a TypeError: "unable to factor n".</p>
<p><strong>Edit</strong>: Part of the problem may have been that the script was in a shared folder in VirtualBox. Here is some exact input/output, working completely locally (this changes the error in (2)).</p>
<p><code>>./factor 2006</code></p>
<p><code>/usr/bin/env: sage -python: No such file or directory</code></p>
<p><code>>sage -python factor "32*x^5-1"</code></p>
<p><code>NameError: name 'x' is not defined</code></p>
<p>Any assistance is much appreciated!</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18909#post-id-18909Thanks. Gee, this really suggests that `from sage.all import *` isn't being done, not to mention the enigmatic no such file problem.Tue, 09 Oct 2012 16:55:26 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18909#post-id-18909Answer by John Palmieri for <p>First of all, my apologies for being a noob and a windows user. I'm using sage in virtualbox. I'm at this part of the tutorial: sagenb.org/doc/live/tutorial/programming.html#standalone-python-sage-scripts</p>
<p>I'm having 2 problems:</p>
<p>(1) I can't execute "./factor 2006". It says "no such file or directory", but the file is definitely there, and "sage -python factor 2006" works.</p>
<p>(2) factoring polynomials doesn't seem to work for me in sage. If I call factor on a string I get a TypeError: "unable to factor n".</p>
<p><strong>Edit</strong>: Part of the problem may have been that the script was in a shared folder in VirtualBox. Here is some exact input/output, working completely locally (this changes the error in (2)).</p>
<p><code>>./factor 2006</code></p>
<p><code>/usr/bin/env: sage -python: No such file or directory</code></p>
<p><code>>sage -python factor "32*x^5-1"</code></p>
<p><code>NameError: name 'x' is not defined</code></p>
<p>Any assistance is much appreciated!</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?answer=14138#post-id-14138Edit: try replacing the first line with `#!/usr/bin/env sage`. That might bypass all of the problems described below.
One more attempt at an answer: perhaps the shell in VirtualBox doesn't accept the syntax `#!/usr/bin/env sage -python` some shells balk at having more than one term after "/usr/bin/env". So changing this first line to `#!/usr/bin/env python` and executing it with `sage -sh -c './factor 2012'` should work, as should first running `sage -sh` and then `./factor 2012`. In either case, `sage -sh` tells `/usr/bin/env python` to use Sage's version of Python, which knows how to import the Sage library (from the line `from sage.all import *`).
That's my guess. See Wikipedia's article on 'Shebang (Unix)' I don't know how to add the link here, since the link has a right parenthesis in it, which conflicts with the markup here for links and in particular the part which says
> Another portability problem is the
> interpretation of the command
> arguments. Some systems, including
> Linux, do not split up the
> arguments;[11] for example, when
> running the script with the first line
> like,
>
> `#!/usr/bin/env python -c`
>
> That is, python -c will be passed as one
> argument to /usr/bin/env, rather than
> two arguments. Cygwin also behaves
> this way.
While the original script (with `#!/usr/bin/env sage -python`) works on my OS X box, it doesn't work on a linux machine that I have access to. This part of the tutorial needs to be fixed, I think.Fri, 12 Oct 2012 16:15:05 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?answer=14138#post-id-14138Comment by John Palmieri for <p>Edit: try replacing the first line with <code>#!/usr/bin/env sage</code>. That might bypass all of the problems described below.</p>
<p>One more attempt at an answer: perhaps the shell in VirtualBox doesn't accept the syntax <code>#!/usr/bin/env sage -python</code> some shells balk at having more than one term after "/usr/bin/env". So changing this first line to <code>#!/usr/bin/env python</code> and executing it with <code>sage -sh -c './factor 2012'</code> should work, as should first running <code>sage -sh</code> and then <code>./factor 2012</code>. In either case, <code>sage -sh</code> tells <code>/usr/bin/env python</code> to use Sage's version of Python, which knows how to import the Sage library (from the line <code>from sage.all import *</code>).</p>
<p>That's my guess. See Wikipedia's article on 'Shebang (Unix)' I don't know how to add the link here, since the link has a right parenthesis in it, which conflicts with the markup here for links and in particular the part which says</p>
<blockquote>
<p>Another portability problem is the
interpretation of the command
arguments. Some systems, including
Linux, do not split up the
arguments;[11] for example, when
running the script with the first line
like,</p>
<pre><code>`#!/usr/bin/env python -c`
</code></pre>
<p>That is, python -c will be passed as one
argument to /usr/bin/env, rather than
two arguments. Cygwin also behaves
this way.</p>
</blockquote>
<p>While the original script (with <code>#!/usr/bin/env sage -python</code>) works on my OS X box, it doesn't work on a linux machine that I have access to. This part of the tutorial needs to be fixed, I think.</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18866#post-id-18866"#!/usr/bin/env sage" as the first line in the script says what program should be used to process the script, in this case "/usr/bin/env sage", so it is equivalent to running "sage factor". Some programs might start with "#!/usr/bin/python", for example, but it's more portable to use "#!/usr/bin/env python" -- the first only finds python if it's in /usr/bin, while the second finds python if it's anywhere in the user's PATH. In this case, the documentation suggested using "#!/usr/bin/env sage -python", to use Sage's installation of Python, but Linux apparently doesn't handle having more than one word after "#!/usr/bin/env" very well. Mon, 15 Oct 2012 08:07:09 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18866#post-id-18866Comment by rmp251 for <p>Edit: try replacing the first line with <code>#!/usr/bin/env sage</code>. That might bypass all of the problems described below.</p>
<p>One more attempt at an answer: perhaps the shell in VirtualBox doesn't accept the syntax <code>#!/usr/bin/env sage -python</code> some shells balk at having more than one term after "/usr/bin/env". So changing this first line to <code>#!/usr/bin/env python</code> and executing it with <code>sage -sh -c './factor 2012'</code> should work, as should first running <code>sage -sh</code> and then <code>./factor 2012</code>. In either case, <code>sage -sh</code> tells <code>/usr/bin/env python</code> to use Sage's version of Python, which knows how to import the Sage library (from the line <code>from sage.all import *</code>).</p>
<p>That's my guess. See Wikipedia's article on 'Shebang (Unix)' I don't know how to add the link here, since the link has a right parenthesis in it, which conflicts with the markup here for links and in particular the part which says</p>
<blockquote>
<p>Another portability problem is the
interpretation of the command
arguments. Some systems, including
Linux, do not split up the
arguments;[11] for example, when
running the script with the first line
like,</p>
<pre><code>`#!/usr/bin/env python -c`
</code></pre>
<p>That is, python -c will be passed as one
argument to /usr/bin/env, rather than
two arguments. Cygwin also behaves
this way.</p>
</blockquote>
<p>While the original script (with <code>#!/usr/bin/env sage -python</code>) works on my OS X box, it doesn't work on a linux machine that I have access to. This part of the tutorial needs to be fixed, I think.</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18871#post-id-18871Thanks a lot - this works.
(As to WHY it works I'm still confused... I guess I don't understand the meaning of the hash-bang and /usr/bin/env)Mon, 15 Oct 2012 07:10:42 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18871#post-id-18871Comment by John Palmieri for <p>Edit: try replacing the first line with <code>#!/usr/bin/env sage</code>. That might bypass all of the problems described below.</p>
<p>One more attempt at an answer: perhaps the shell in VirtualBox doesn't accept the syntax <code>#!/usr/bin/env sage -python</code> some shells balk at having more than one term after "/usr/bin/env". So changing this first line to <code>#!/usr/bin/env python</code> and executing it with <code>sage -sh -c './factor 2012'</code> should work, as should first running <code>sage -sh</code> and then <code>./factor 2012</code>. In either case, <code>sage -sh</code> tells <code>/usr/bin/env python</code> to use Sage's version of Python, which knows how to import the Sage library (from the line <code>from sage.all import *</code>).</p>
<p>That's my guess. See Wikipedia's article on 'Shebang (Unix)' I don't know how to add the link here, since the link has a right parenthesis in it, which conflicts with the markup here for links and in particular the part which says</p>
<blockquote>
<p>Another portability problem is the
interpretation of the command
arguments. Some systems, including
Linux, do not split up the
arguments;[11] for example, when
running the script with the first line
like,</p>
<pre><code>`#!/usr/bin/env python -c`
</code></pre>
<p>That is, python -c will be passed as one
argument to /usr/bin/env, rather than
two arguments. Cygwin also behaves
this way.</p>
</blockquote>
<p>While the original script (with <code>#!/usr/bin/env sage -python</code>) works on my OS X box, it doesn't work on a linux machine that I have access to. This part of the tutorial needs to be fixed, I think.</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18890#post-id-18890See http://trac.sagemath.org/sage_trac/ticket/13597 for a ticket tracking this problem.Fri, 12 Oct 2012 16:21:39 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18890#post-id-18890Comment by rmp251 for <p>Edit: try replacing the first line with <code>#!/usr/bin/env sage</code>. That might bypass all of the problems described below.</p>
<p>One more attempt at an answer: perhaps the shell in VirtualBox doesn't accept the syntax <code>#!/usr/bin/env sage -python</code> some shells balk at having more than one term after "/usr/bin/env". So changing this first line to <code>#!/usr/bin/env python</code> and executing it with <code>sage -sh -c './factor 2012'</code> should work, as should first running <code>sage -sh</code> and then <code>./factor 2012</code>. In either case, <code>sage -sh</code> tells <code>/usr/bin/env python</code> to use Sage's version of Python, which knows how to import the Sage library (from the line <code>from sage.all import *</code>).</p>
<p>That's my guess. See Wikipedia's article on 'Shebang (Unix)' I don't know how to add the link here, since the link has a right parenthesis in it, which conflicts with the markup here for links and in particular the part which says</p>
<blockquote>
<p>Another portability problem is the
interpretation of the command
arguments. Some systems, including
Linux, do not split up the
arguments;[11] for example, when
running the script with the first line
like,</p>
<pre><code>`#!/usr/bin/env python -c`
</code></pre>
<p>That is, python -c will be passed as one
argument to /usr/bin/env, rather than
two arguments. Cygwin also behaves
this way.</p>
</blockquote>
<p>While the original script (with <code>#!/usr/bin/env sage -python</code>) works on my OS X box, it doesn't work on a linux machine that I have access to. This part of the tutorial needs to be fixed, I think.</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18861#post-id-18861I see - thanks.Mon, 15 Oct 2012 10:19:42 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18861#post-id-18861Answer by John Palmieri for <p>First of all, my apologies for being a noob and a windows user. I'm using sage in virtualbox. I'm at this part of the tutorial: sagenb.org/doc/live/tutorial/programming.html#standalone-python-sage-scripts</p>
<p>I'm having 2 problems:</p>
<p>(1) I can't execute "./factor 2006". It says "no such file or directory", but the file is definitely there, and "sage -python factor 2006" works.</p>
<p>(2) factoring polynomials doesn't seem to work for me in sage. If I call factor on a string I get a TypeError: "unable to factor n".</p>
<p><strong>Edit</strong>: Part of the problem may have been that the script was in a shared folder in VirtualBox. Here is some exact input/output, working completely locally (this changes the error in (2)).</p>
<p><code>>./factor 2006</code></p>
<p><code>/usr/bin/env: sage -python: No such file or directory</code></p>
<p><code>>sage -python factor "32*x^5-1"</code></p>
<p><code>NameError: name 'x' is not defined</code></p>
<p>Any assistance is much appreciated!</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?answer=14127#post-id-14127It's possible that the file is there but doesn't have the right permissions: it isn't executable. You could try
$ chmod a+x factor
$ ./factor 2006
and see if that works.
Tue, 09 Oct 2012 12:20:51 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?answer=14127#post-id-14127Comment by rmp251 for <p>It's possible that the file is there but doesn't have the right permissions: it isn't executable. You could try</p>
<pre><code>$ chmod a+x factor
$ ./factor 2006
</code></pre>
<p>and see if that works.</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18911#post-id-18911Thanks for the suggestion - I tried it and got an error (see my edit please).Tue, 09 Oct 2012 16:48:13 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18911#post-id-18911Answer by kcrisman for <p>First of all, my apologies for being a noob and a windows user. I'm using sage in virtualbox. I'm at this part of the tutorial: sagenb.org/doc/live/tutorial/programming.html#standalone-python-sage-scripts</p>
<p>I'm having 2 problems:</p>
<p>(1) I can't execute "./factor 2006". It says "no such file or directory", but the file is definitely there, and "sage -python factor 2006" works.</p>
<p>(2) factoring polynomials doesn't seem to work for me in sage. If I call factor on a string I get a TypeError: "unable to factor n".</p>
<p><strong>Edit</strong>: Part of the problem may have been that the script was in a shared folder in VirtualBox. Here is some exact input/output, working completely locally (this changes the error in (2)).</p>
<p><code>>./factor 2006</code></p>
<p><code>/usr/bin/env: sage -python: No such file or directory</code></p>
<p><code>>sage -python factor "32*x^5-1"</code></p>
<p><code>NameError: name 'x' is not defined</code></p>
<p>Any assistance is much appreciated!</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?answer=14126#post-id-14126Here's a link that everyone can access: [the tutorial on standalone scripts](http://www.sagemath.org/doc/tutorial/programming.html#standalone-python-sage-scripts).
1) Is it possible that you aren't in the appropriate directory? Just a guess. What happens if you type `ls`? Sorry if this is too naive of question.
2) Strings can't be factored; polynomials can.
sage: P = 'x^2+x'
sage: P.factor()
---------------------------------------------------------------------------
AttributeError: 'str' object has no attribute 'factor'
sage: (x^2+x).factor()
(x + 1)*x
sage: R.<y> = ZZ[]
sage: R
Univariate Polynomial Ring in y over Integer Ring
sage: (y^2+y).factor()
y * (y + 1)
Of course, I didn't get your error message, so maybe something else is going on.Tue, 09 Oct 2012 10:41:37 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?answer=14126#post-id-14126Comment by rmp251 for <p>Here's a link that everyone can access: <a href="http://www.sagemath.org/doc/tutorial/programming.html#standalone-python-sage-scripts">the tutorial on standalone scripts</a>.</p>
<p>1) Is it possible that you aren't in the appropriate directory? Just a guess. What happens if you type <code>ls</code>? Sorry if this is too naive of question.</p>
<p>2) Strings can't be factored; polynomials can.</p>
<pre><code>sage: P = 'x^2+x'
sage: P.factor()
---------------------------------------------------------------------------
AttributeError: 'str' object has no attribute 'factor'
sage: (x^2+x).factor()
(x + 1)*x
sage: R.<y> = ZZ[]
sage: R
Univariate Polynomial Ring in y over Integer Ring
sage: (y^2+y).factor()
y * (y + 1)
</code></pre>
<p>Of course, I didn't get your error message, so maybe something else is going on.</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18912#post-id-18912Thanks for the response.
1) I'm in the appropriate directory and ls verifies that.
2) I see. I guess it is passed as a string argument but then is converted to an expression for sage. Please see my edit. Since the tutorial is for "standalone scripts" I would expect this to work.Tue, 09 Oct 2012 16:43:12 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18912#post-id-18912Comment by kcrisman for <p>Here's a link that everyone can access: <a href="http://www.sagemath.org/doc/tutorial/programming.html#standalone-python-sage-scripts">the tutorial on standalone scripts</a>.</p>
<p>1) Is it possible that you aren't in the appropriate directory? Just a guess. What happens if you type <code>ls</code>? Sorry if this is too naive of question.</p>
<p>2) Strings can't be factored; polynomials can.</p>
<pre><code>sage: P = 'x^2+x'
sage: P.factor()
---------------------------------------------------------------------------
AttributeError: 'str' object has no attribute 'factor'
sage: (x^2+x).factor()
(x + 1)*x
sage: R.<y> = ZZ[]
sage: R
Univariate Polynomial Ring in y over Integer Ring
sage: (y^2+y).factor()
y * (y + 1)
</code></pre>
<p>Of course, I didn't get your error message, so maybe something else is going on.</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18908#post-id-18908Yes, see my comment - `from sage.all import *` should make `x` predefined as a variable.Tue, 09 Oct 2012 16:55:53 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18908#post-id-18908Answer by John Palmieri for <p>First of all, my apologies for being a noob and a windows user. I'm using sage in virtualbox. I'm at this part of the tutorial: sagenb.org/doc/live/tutorial/programming.html#standalone-python-sage-scripts</p>
<p>I'm having 2 problems:</p>
<p>(1) I can't execute "./factor 2006". It says "no such file or directory", but the file is definitely there, and "sage -python factor 2006" works.</p>
<p>(2) factoring polynomials doesn't seem to work for me in sage. If I call factor on a string I get a TypeError: "unable to factor n".</p>
<p><strong>Edit</strong>: Part of the problem may have been that the script was in a shared folder in VirtualBox. Here is some exact input/output, working completely locally (this changes the error in (2)).</p>
<p><code>>./factor 2006</code></p>
<p><code>/usr/bin/env: sage -python: No such file or directory</code></p>
<p><code>>sage -python factor "32*x^5-1"</code></p>
<p><code>NameError: name 'x' is not defined</code></p>
<p>Any assistance is much appreciated!</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?answer=14132#post-id-14132Given the error message in
>./factor 2006
/usr/bin/env: sage -python: No such file or directory
It looks like "sage" can't be found, so I would guess that you haven't followed this direction from the tutorial:
> In order to use this script, your SAGE_ROOT must be in your PATH.
I don't know how to do this using VirtualBox, but it might be this: find the directory `SAGE_ROOT` where `sage` is; say it's "/home/user/sage-5.3/". Then do
> export PATH=/home/user/sage-5.3/:$PATH
(There should be exactly one space in this line, between "export" and "PATH".) Then try
> ./factor 2006
again.Wed, 10 Oct 2012 07:55:51 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?answer=14132#post-id-14132Comment by rmp251 for <p>Given the error message in</p>
<pre><code>>./factor 2006
/usr/bin/env: sage -python: No such file or directory
</code></pre>
<p>It looks like "sage" can't be found, so I would guess that you haven't followed this direction from the tutorial:</p>
<blockquote>
<p>In order to use this script, your SAGE_ROOT must be in your PATH.</p>
</blockquote>
<p>I don't know how to do this using VirtualBox, but it might be this: find the directory <code>SAGE_ROOT</code> where <code>sage</code> is; say it's "/home/user/sage-5.3/". Then do</p>
<pre><code>> export PATH=/home/user/sage-5.3/:$PATH
</code></pre>
<p>(There should be exactly one space in this line, between "export" and "PATH".) Then try</p>
<pre><code>> ./factor 2006
</code></pre>
<p>again.</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18897#post-id-18897sage is in the path:
> echo $PATH
/home/sage/sage:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbinThu, 11 Oct 2012 16:17:02 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18897#post-id-18897Comment by John Palmieri for <p>Given the error message in</p>
<pre><code>>./factor 2006
/usr/bin/env: sage -python: No such file or directory
</code></pre>
<p>It looks like "sage" can't be found, so I would guess that you haven't followed this direction from the tutorial:</p>
<blockquote>
<p>In order to use this script, your SAGE_ROOT must be in your PATH.</p>
</blockquote>
<p>I don't know how to do this using VirtualBox, but it might be this: find the directory <code>SAGE_ROOT</code> where <code>sage</code> is; say it's "/home/user/sage-5.3/". Then do</p>
<pre><code>> export PATH=/home/user/sage-5.3/:$PATH
</code></pre>
<p>(There should be exactly one space in this line, between "export" and "PATH".) Then try</p>
<pre><code>> ./factor 2006
</code></pre>
<p>again.</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18896#post-id-18896From the command line, what does "which sage" say?Fri, 12 Oct 2012 04:32:13 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18896#post-id-18896Comment by John Palmieri for <p>Given the error message in</p>
<pre><code>>./factor 2006
/usr/bin/env: sage -python: No such file or directory
</code></pre>
<p>It looks like "sage" can't be found, so I would guess that you haven't followed this direction from the tutorial:</p>
<blockquote>
<p>In order to use this script, your SAGE_ROOT must be in your PATH.</p>
</blockquote>
<p>I don't know how to do this using VirtualBox, but it might be this: find the directory <code>SAGE_ROOT</code> where <code>sage</code> is; say it's "/home/user/sage-5.3/". Then do</p>
<pre><code>> export PATH=/home/user/sage-5.3/:$PATH
</code></pre>
<p>(There should be exactly one space in this line, between "export" and "PATH".) Then try</p>
<pre><code>> ./factor 2006
</code></pre>
<p>again.</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18891#post-id-18891When you just do "./factor", it's using a non-Sage version of Python. If you do "sage -sh" and then "./factor 2006", I think it should work. Maybe "./sage -sh -c './factor 2006' would work, too.Fri, 12 Oct 2012 07:51:48 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18891#post-id-18891Comment by John Palmieri for <p>Given the error message in</p>
<pre><code>>./factor 2006
/usr/bin/env: sage -python: No such file or directory
</code></pre>
<p>It looks like "sage" can't be found, so I would guess that you haven't followed this direction from the tutorial:</p>
<blockquote>
<p>In order to use this script, your SAGE_ROOT must be in your PATH.</p>
</blockquote>
<p>I don't know how to do this using VirtualBox, but it might be this: find the directory <code>SAGE_ROOT</code> where <code>sage</code> is; say it's "/home/user/sage-5.3/". Then do</p>
<pre><code>> export PATH=/home/user/sage-5.3/:$PATH
</code></pre>
<p>(There should be exactly one space in this line, between "export" and "PATH".) Then try</p>
<pre><code>> ./factor 2006
</code></pre>
<p>again.</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18893#post-id-18893What happens if you replace first line of "factor" with "/usr/bin/env python" and then do "sage -sh -c ./factor"?Fri, 12 Oct 2012 05:20:02 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18893#post-id-18893Comment by rmp251 for <p>Given the error message in</p>
<pre><code>>./factor 2006
/usr/bin/env: sage -python: No such file or directory
</code></pre>
<p>It looks like "sage" can't be found, so I would guess that you haven't followed this direction from the tutorial:</p>
<blockquote>
<p>In order to use this script, your SAGE_ROOT must be in your PATH.</p>
</blockquote>
<p>I don't know how to do this using VirtualBox, but it might be this: find the directory <code>SAGE_ROOT</code> where <code>sage</code> is; say it's "/home/user/sage-5.3/". Then do</p>
<pre><code>> export PATH=/home/user/sage-5.3/:$PATH
</code></pre>
<p>(There should be exactly one space in this line, between "export" and "PATH".) Then try</p>
<pre><code>> ./factor 2006
</code></pre>
<p>again.</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18892#post-id-18892That seems to work, although I can't seem to pass in a parameter to factor that way.
Now when I just do ./factor 2006, for example, I get
ImportError: No module named sage.allFri, 12 Oct 2012 07:13:22 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18892#post-id-18892Comment by rmp251 for <p>Given the error message in</p>
<pre><code>>./factor 2006
/usr/bin/env: sage -python: No such file or directory
</code></pre>
<p>It looks like "sage" can't be found, so I would guess that you haven't followed this direction from the tutorial:</p>
<blockquote>
<p>In order to use this script, your SAGE_ROOT must be in your PATH.</p>
</blockquote>
<p>I don't know how to do this using VirtualBox, but it might be this: find the directory <code>SAGE_ROOT</code> where <code>sage</code> is; say it's "/home/user/sage-5.3/". Then do</p>
<pre><code>> export PATH=/home/user/sage-5.3/:$PATH
</code></pre>
<p>(There should be exactly one space in this line, between "export" and "PATH".) Then try</p>
<pre><code>> ./factor 2006
</code></pre>
<p>again.</p>
https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18894#post-id-18894~/sage/sage
which I believe is the same thing as
/home/sage/sage/sageFri, 12 Oct 2012 04:47:48 -0500https://ask.sagemath.org/question/9407/pythonsage-scripts/?comment=18894#post-id-18894