How to install sagemath kernel in Jupyter

感情迁移 提交于 2021-01-20 14:34:11

问题


I could use Python Kernel with Jupyter. I am looking for a way to use sagemath inside Jupyter.I couldnt see a way for installing it. How to do that?


回答1:


You are going about it backwards; Sage includes the Jupyter notebook inside of it, and you can use it with that kernel that way. (As well as others.) Use

$ sage --notebook ipython

I believe. See also here.

(I think there are also some people who have had success redirecting their Jupyter to "see" the Sage kernel by editing some file or configuration. On Arch Linux this is apparently supported ... ?)




回答2:


I have just installed SageMath kernel on my existing Jupyter installation. It's super easy.

$ sudo jupyter kernelspec install ./SageMath/local/share/jupyter/kernels/sagemath

Where SageMath is your root sagemath directory. Hope this will help someone.

If you don't have sudo rights you won't be able to install system-wide, but you can still install for yourself using the --user flag:

$ jupyter kernelspec install --user ./SageMath/local/share/jupyter/kernels/sagemath



回答3:


The answer suggesting

$ jupyter kernelspec install --user <path to SageMath/local/share/jupyter/kernels/sagemath>

works only if you provide the environment variable SAGE_ROOT in the kernel spec. This requires adding an "env" item to the kernel.json. The line that must be added is:

"env":{"SAGE_ROOT":"<Path to sage root>"}

An example specific to an installed mac app for version 8.7 is:

"env":{"SAGE_ROOT":"/Applications/SageMath-8.7.app/Contents/Resources/sage"}

See this question for general information and a complete example.




回答4:


I know this is an old question, but I stumbled onto it and ended up making a docker container to accomplish this for anyone who is interested.

https://hub.docker.com/r/sharptrick/sage-notebook

The dockerfile may be of interest as it has explicit instructions which install the kernel to the official "jupyter/minimal-notebook".

https://github.com/sharpTrick/sage-notebook/blob/master/Dockerfile



来源:https://stackoverflow.com/questions/39296020/how-to-install-sagemath-kernel-in-jupyter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!