在Python中使用Sage Math库

Chi*_*xit 1 python sage python-2.7

我正在尝试使用Sage对图形进行可视化.我需要完全像编写Python代码一样进行可视化.

我已经下载并安装了Sage for Ubuntu和Sage Notebook正常运行.但我想从Tkinter获取用户输入,然后在Graph上显示这些输入(由Sage生成).但是,我无法在Python Shell中导入sage.我怎么能这样做?

Mic*_*x2a 5

从查看常见问题解答,看起来您需要做的是将以下行添加到Python文件中:

from sage.all import *
Run Code Online (Sandbox Code Playgroud)

然后,看起来您需要使用命令行/控制台中与Sage捆绑的Python解释器来运行脚本:

sage -python /path/to/my/script.py
Run Code Online (Sandbox Code Playgroud)

但是,如果要直接从shell使用Sage,则应该尝试使用交互式shell.(只需输入命令行sagesage -python从命令行输入)

警告:我自己没有测试任何这些,所以你可能需要做一些实验来让一切工作.

  • 使用`sage -ipython`对此特别好. (2认同)