如何在 Google Colaboratory 中导入 sagemath?

问题描述 投票:0回答:3

能给我一个如何在 Google Colaboratory 中导入 sagemath 的示例吗?这不起作用:

!pip install sage
from sage.all import *
python sage google-colaboratory
3个回答
7
投票

在 Google Colaboratory 提供 SageMath 之前,有各种 在线使用 SageMath 和/或在 SageMath 上进行协作的方法 工作表:


5
投票

Sage 不仅仅是一个

pip
可安装的软件包;目前没有直接从 Colab 使用 sage 的简单方法。

(请注意,上面的

pip install sage
命令正在安装一个完全不同的包;还有一个sagemath包,但不包括sage的所有组件。)


0
投票

这对我有用:

  1. 在colab中安装conda
  2. 在conda内安装sage

问题:

  1. 在你想使用鼠尾草的每个单元格的开头,你必须使用这个:
    %%bash
    source activate sage
  1. 实际上,这个“解决方案”只能在colab中使用sage,它绝对不是一个正确的完整解决方案

安装:

    !pip install -q condacolab
    import condacolab
    condacolab.install()
    !conda create -n sage sage python=X  # X is version of python, for instance 3.9 

现在开始你的程序

%%bash
source activate sage
sage -c '
YOUR CODE HERE
'
© www.soinside.com 2019 - 2024. All rights reserved.