Ask Your Question

Revision history [back]

You can not use the native python of your Ubuntu that does not know anything about Sage functions. One possibility might be to use the python inside Sage

#!/complete/path/to/sage -python 

import sage.all  # this is mandatory to initialize Sage

from sage.rings.arith import factor
print factor(18)

It seems not possible to use /usr/bin/env in conjunction with options...

You can not use the native python of your Ubuntu that does not know anything about Sage functions. One possibility might be to use the python inside SageABCDEFGHIJK

#!/complete/path/to/sage -python 

import sage.all  # this is mandatory to initialize Sage

from sage.rings.arith import factor
print factor(18)

It seems not possible to use /usr/bin/env in conjunction with options...

ABCDEFGHIJKYou can not use the native python of your Ubuntu and call Sage functions. The native Python does not know anything about Sage functions. One possibility might be to use the Python from Sage. Just write a file "my_script" (no extension is needed) with

#!/complete/path/to/sage -python

import sage.all  # this is mandatory to initialize Sage

from sage.rings.arith import factor
print factor(18)

Then from the console do

$ ./my_script
2 * 3^2

Note that the magic of the #! just tells bash to use the Python from Sage. It has nothing to do with native Python versus Sage's Python.

extra remark: It seems not possible to use /usr/bin/env in conjunction with options...