如何在 python 上使用 sagemath?

nem*_*emy 6 python sage

我想使用 sagemath 的立方体组。我做了如下。

python -m pip install sagemath
Run Code Online (Sandbox Code Playgroud)

进而

import sagemath.cubegroup;
Run Code Online (Sandbox Code Playgroud)

在Python脚本中。但我收到以下错误。

ImportError: No module named cubegroup
Run Code Online (Sandbox Code Playgroud)

我尝试了 python2 和 python3 但都不起作用。我也尝试过用 sage 代替 sagemath,但也没有用。

如何在Python上使用sagemath和cubegroup?

Sam*_*vre 2

PyPI 上的 sagemath 包,您可以通过运行获得

python -m pip install sagemath
Run Code Online (Sandbox Code Playgroud)

不安装Sage,它只允许检查Sage是否安装。

看来您正在 Windows 上工作,并且使用 Sage-Windows 安装程序安装了 Sage。

命令

import sage.cubegroup
Run Code Online (Sandbox Code Playgroud)

仅当您使用 Sage 的 Python 时才有效。

如果您通过某些集成开发环境(例如 PyCharm)使用 Python,则需要将其设置为使用 Sage 的 Python。请参阅 Iguananaut 的回答中的说明: