Hello all, I am currently introducing myself to Sage, already having a fair level of python experience. I have installed SageMath 7.5.1 via the Launchpad PPA onto my Chromebook, which is running an Ubuntu 14.04 chroot on Intel x86_64 architecture.
I wish to use Sage via standalone scripts, as detailed in the official tutorial <http://doc.sagemath.org/html/en/tutorial/programming.html#section-standalone>. However, I am having trouble running their example factoring script. When I attempt to factor polynomials, such as by giving the script the argument "32*x^5-1", I get the following error trace: Traceback (most recent call last): File "./test", line 11, in <module> print(factor(sage_eval(sys.argv[1]))) File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/misc/sage_eval.py", line 201, in sage_eval return eval(source, sage.all.__dict__, locals) File "<string>", line 1, in <module> NameError: name 'x' is not defined I found that to make the script work, I need to add var('x') to declare x, as well as a dictionary, {'x':x}, for the locals parameter of the sage_eval function. I'm confused, because everything I've read says that x is already declared before the interpreter starts running my script, hence why the code in the tutorial doesn't need to declare it or notify sage_eval. I'd like to make sure that my installation can run code as given, and that it is generally compliant with information from official sources, and I'd also prefer (but am not terribly attached to) keeping with the PPA. Sorry for being lazy, but I haven't tried building the latest version from source and trying that. I'll post up if that solves the issue. P.S. I know the guidelines asked to keep a single post confined to one question, but my ultimate goal here is to understand the functionality of the interpreter, preparser, and execution of the sage binary. I'd like to have fully fledged standalone scripts, that is, a Sage script (that doesn't need to end in .sage) that can be preparsed and executed with a single call to some utility. It would be great if I could manage to preparse into memory and let the interpreter run the script from there, but my general goal is just redirection of preparser output so that my work environment isn't cluttered with .py scripts that I need to manually organize. I just need to grasp the interpreter and preparser enough so that I know what combination of Sage development and shell scripting can be used to achieve this. Any pointers would be greatly appreciated. Thanks, -Nick -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.