在Python中使用独立的智能功能

2024-06-01 06:39:44 发布

您现在位置:Python中文网/ 问答频道 /正文

sage中有一个函数latex,我想直接从命令行使用它,而不需要插入sage客户端。我认为有一种可能的方法是将sage模块包含到我的python脚本中。

使用pip install sage不起作用。

有什么想法吗?


Tags: 模块installpip方法函数命令行脚本客户端
2条回答

您不能将Sage作为一个带有包的包来安装,而且Sage中有大量的非Python代码,因此很难事先做到这一点。

不过,你可以很容易地从脚本中调用Sage。Here就是一个例子。

对于任何发现这一点的人来说,通常ask.sagemath.org将是获得响应的一种更快的方法-我甚至不知道stackoverflow有一个Sage标记。

是的,但仅当您使用与Sage捆绑在一起的特殊版本Python运行脚本时。

从圣人的文件http://www.sagemath.org/doc/faq/faq-usage.html#how-do-i-import-sage-into-a-python-script

You can import Sage as a library in a Python script. One caveat is that you need to run that Python script using the version of Python that is bundled with Sage; currently Python 2.6.x. To import Sage, put the following in your Python script:

from sage.all import *

相关问题 更多 >