Using Sage Math library within Python

python, python-2.7, sage

Solution

From looking at the faq, it looks like what you need to do is add the following line to your Python file:

from sage.all import *

Then, it looks like you need to run your script by using the Python interpreter bundled with Sage from the command line/console:

sage -python /path/to/my/script.py

However, if you want to use Sage directly from the shell, you should probably try using the interactive shell. (just type in `sage` or maybe `sage -python` from the command line)

Caveat: I haven't tested any of this myself, so you might need to do a bit of experimenting to get everything to work.

Problem

I am trying to make a visualization of a graph using Sage. I need to make the visualization exactly as I am writing the Python code. I have downloaded and installed the Sage for Ubuntu and Sage Notebook is working perfectly. But I want to take user input from Tkinter and then show those input on the Graph (generated by Sage). However, I am unable to import sage in the Python Shell. How can I do so?

Original source