1

My Situation

When I'm using the sage.all module just on the normal python shell, sage.all throws an error on running methods like solve or assume:

>>> import sage.all as sg;a=sg.var('a');sg.assume(a==0);
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/sage/local/lib/python2.7/site-packages/sage/symbolic/assumptions.py", line 412, in assume
    x.assume()
  File "expression.pyx", line 1397, in sage.symbolic.expression.Expression.assume (sage/symbolic/expression.cpp:8428)
  File "lazy_import.pyx", line 212, in sage.misc.lazy_import.LazyImport.__getattr__ (sage/misc/lazy_import.c:1865)
  File "lazy_import.pyx", line 148, in sage.misc.lazy_import.LazyImport._get_object (sage/misc/lazy_import.c:1268)
  File "/opt/sage/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py", line 153, in <module>
    ecl_eval("#$%s$"%l)
  File "ecl.pyx", line 1236, in sage.libs.ecl.ecl_eval (sage/libs/ecl.c:7040)
  File "ecl.pyx", line 1251, in sage.libs.ecl.ecl_eval (sage/libs/ecl.c:6977)
  File "ecl.pyx", line 257, in sage.libs.ecl.ecl_safe_eval (sage/libs/ecl.c:2839)
RuntimeError: ECL says: THROW: The catch MACSYMA-QUIT is undefined.

Running assume or solve on the sage shell (and preprocessor) works like it is supposed to do.

My Question

What can I do to get sage.all to work correctly on python?

Thanks - if anything's unclear concerning my question, please comment.

Community
  • 1
  • 1
fdj815
  • 569
  • 1
  • 7
  • 15

1 Answers1

3

I would just use the Sage copy of the IPython shell.

$ sage -ipython
Python 2.7.3 (default, Feb 16 2013, 21:48:36) 
Type "copyright", "credits" or "license" for more information.
IPython 0.13.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import sage.all as sg

In [2]: a = sg.var('a')

In [3]: sg.assume(a==0)

In [4]: 
kcrisman
  • 4,374
  • 20
  • 41
  • 1
    To amplify: Sage is more than just a Python library — it requires various other components be present and located in specific places. So using `sage --python` (or `sage --ipython`) will use a version of Python which has access to all of the relevant components. – John Palmieri Mar 05 '13 at 04:09
  • @JohnPalmieri Is it just impossible to run Python scripts using `sage.all` on a normal Python interpreter? Or are there special things I can do to get `sage.all` running? (I don't need/want Sage's Python preprocessor, I just write normal Python scripts accessing the `sage.all` module) – fdj815 Mar 05 '13 at 05:41
  • `sage --python` runs a normal Python interpreter, with no preprocessor. Try it: evaluate `2^3`, for example. But Sage's library will run commands like `maxima` and `cython` and `Singular`, and it will also try to access various libraries. It is not just a self-contained Python library. – John Palmieri Mar 05 '13 at 15:35