Ask Your Question

how to execute *.sage files?

asked 2012-09-02 05:59:32 +0100

anonymous user



Could anyone tell me how to execute *.sage files? I fail it as follows:

% sw_vers
ProductName:    Mac OS X
ProductVersion: 10.7.4
BuildVersion:   11E53 
$ hdiutil mount /Users/me/Downloads/sage-5.2-OSX-64bit-10.6-x86_64-Darwin.dmg
$ cp -R -P /Volumes/sage-5.2-OSX-64bit-10.6-x86_64-Darwin/sage /Applications
$ open /Applications/sage/sage
$ sage
| Sage Version 5.2, Release Date: 2012-07-25                         |
| Type "notebook()" for the browser-based notebook interface.        |
| Type "help()" for help.                                            |
sage: 1 + 1
sage: quit
Exiting Sage (CPU time 0m0.05s, Wall time 0m6.00s).
$ env | grep '/sage'
$ cat test.sage
1 + 1
$ sage test.sage
$ ls -d test.*     test.sage
$ cat
# This file was *autogenerated* from the file test.sage.
from sage.all_cmdline import *   # import sage library
_sage_const_1 = Integer(1)
_sage_const_1  + _sage_const_1 
$ $SAGE_ROOT/local/bin/python
Traceback (most recent call last):
  File "", line 2, in <module>
    from sage.all_cmdline import *   # import sage library
  File "/Applications/sage/local/lib/python2.7/site-packages/sage/", line 14, in <module>
    from sage.all import *
  File "/Applications/sage/local/lib/python2.7/site-packages/sage/", line 61, in <module>
    from sage.ext.c_lib import _init_csage, sig_on_count
ImportError: dlopen(/Applications/sage/local/lib/python2.7/site-packages/sage/ext/, 2): Library not loaded: libcsage.dylib
  Referenced from: /Applications/sage/local/lib/python2.7/site-packages/sage/ext/
  Reason: image not found
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-09-02 07:03:45 +0100

Volker Braun gravatar image

This is correct:

$ sage test.sage

Note that if you run a Sage script, the output of each command is not printed like on the command line. This is a general convention and how Python works. Similarly, a shell script doesn't echo each line either. If you want text to appear on the output you have to add a manual print 1+1 command.

If you want to manually run the Python in Sage you can't directly call $ $SAGE_ROOT/local/bin/python. Some environment variables need to be set up first. Instead, use

sage -python
edit flag offensive delete link more

answered 2012-09-02 12:58:13 +0100

kd gravatar image

Thank you for answer. I am now satisfied by another trial with a "print" command:

$ cat test2.sage
assume(x > 0)
print bool(sqrt(x^2) == x)
$ sage test2.sage
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-09-02 05:59:32 +0100

Seen: 4,424 times

Last updated: Sep 02 '12