首页 > 解决方案 > 有没有办法在 macOS Big Sur 上使用 SageMath?

问题描述

我在我的mac上下载SageMath-9.2的,但每次我尝试使用笔记本时

sage -n jupyter通过在我的终端上运行“ ”

我得到以下按摩:

Please wait while the Sage Jupyter Notebook server starts... 
Traceback (most recent call last): 
    File "/Applications/SageMath-9.2.app/Contents/Resources/sage/local/lib/python3.8/site-packages/sage/repl/ipython_kernel/install.py", line 307, in have_prerequisites 
        from notebook.notebookapp import NotebookApp 
    File "/Applications/SageMath-9.2.app/Contents/Resources/sage/local/lib/python3.8/site-packages/notebook/notebookapp.py", line 66, in 
        from tornado import httpserver 
    File "/Applications/SageMath-9.2.app/Contents/Resources/sage/local/lib/python3.8/site-packages/tornado/httpserver.py", line 29, in 
        import ssl 
    File "/Applications/SageMath-9.2.app/Contents/Resources/sage/local/lib/python3.8/ssl.py", line 98, in
        import _ssl # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'

The Jupyter notebook requires ssl, even if you do not use https. Install the openssl development packages in your system and then rebuild Python (sage -f python3).

而且由于某种原因我也无法打开该应用程序.....每次单击该应用程序时,我都会看到一个小窗口说:

Jupyter Server failed to start 
For some reason the Jupyter server failed to start. Please check the log for clues, and have that information handy when asking for help.

我希望能得到一些帮助,这对我来说非常重要,因为我必须将 SageMath 用于我的大学项目.. 提前致谢

标签: pythonmacosjupyter-notebooksage

解决方案


在 macOS Big Sur 上,有几种方法可以安装 SageMath

Sage 也可以在线使用

您当前的安装是作为 macOS 应用程序下载的,该应用程序带有自己的 Python,但缺少 SSL 模块(出于许可原因)。

要修复它:

  • 切换到 Sage 目录
  • 可选择获取最新的开发版本
  • 设置并行运行的作业数
  • 摆脱那个 Sage 的 Python
  • 配置
  • 可选地遵循brew install 配置结束时的建议
  • 制作
$ DIR=/Applications/SageMath-9.2.app/Contents/Resources/sage
$ cd $DIR
$ git checkout develop
$ git pull origin develop --tags
$ MAKE='make -j8'
$ V=0
$ source .homebrew-build-env
$ make -s V=0 python3-clean
$ make -s V=0 configure
$ ./configure
$ make -s V=0

解决问题的另一种方法是将 Sage 提供的 SageMath Jupyter 内核与系统范围的 Jupyter 一起使用(例如,通过 Homebrew 安装)。

这应该实现该目标:

$ SAGE_LOCAL=`sage -c 'print(SAGE_LOCAL)'`
$ SAGE_KERNEL=$SAGE_LOCAL/share/jupyter/kernels/sagemath 
$ KERNELS=$HOME/Library/Jupyter/kernels
$ ln -s $SAGE_KERNEL $KERNELS

推荐阅读