0%

Ubuntu安装sagemath

Ubuntu用下述代码安装sagemath.

1
2
3
4
sudo -i
apt update
apt-get update
apt install sagemath

接下来配置jupyter notebook:
1
jupyter notebook --generate-config %生成配置notebook文件 ~/.jupyter/jupyter_notebook_config.py

2.配置密码,Enter输入密码:
1
jupyter notebook password      

3.找到jupyter_notebook_config.json文件将生成的sha1值粘贴到配置文件 ~/.jupyter/jupyter_notebook_config.py中的

1
c.NotebookApp.password= u'sha1:90a:b587138cffah678kj8ldd811286fcabh9383kghr55c05fb3b42’

配置 jupyter_notebook_config.py 文件:

1
2
3
4
5
6
c.NotebookApp.allow_root = True
c.NotebookApp.ip = '*' %所有IP都可访问(204行)
c.NotebookApp.open_browser = False`%浏览器默认不打开,272行
.NotebookApp.password= u'sha1:90a049f89a1e:b587138cffah678kj8ldd811286fcabh9383kghr55c05fb3b42'%(281行)
c.NotebookApp.port = 8888 %外部访问端口号293行
c.NotebookApp.notebook_dir = '/xxx/jupyters' # 设置jupyter文件存储目录

此过程密码格式填写错误可能回启动不了jupyter. 注意每行编辑后要顶格, 不留空.
上述配置完成后用代码

1
jupyter notebook --allow-root

启动.

后台启动命令:

1
nohup jupyter notebook --allow-root >jupyter.log 2>&1 &

关闭后台程序:

1
2
 ps -ef | grep jupyter %查看jupyter的进程ID
kill -9 PID %PiD替换称刚才的ID号

在jupyter notebook中下载文件为pdf.
安装Tex live 即可.
1
sudo apt-get install texlive-xetex texlive-fonts-recommended texlive-plain-generic

jupyter notebook使用PARI/GP.

首先切换到root用户, 使用如下命令加入PARI内核.

1
pip install pari-jupyter

重新启动jupyter.