【问题标题】:Is there any way to use SageMath on macOS Big Sur?有没有办法在 macOS Big Sur 上使用 SageMath?
【发布时间】:2021-02-26 12:25:03
【问题描述】:

我在我的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 用于我的大学项目.. 在此先感谢

【问题讨论】:

  • 我尝试使用的 SageMath 版本是 9.2 ,我使用的是 Python 3.8.5
  • 欢迎来到 Stack Overflow!您可以随时编辑您的问题。最好在问题本身中添加更多信息。
  • 收到这个错误真的很奇怪。也许问题不是隐含的……“ssl”或“_ssl”模块都无法导入。我这样说是因为我刚刚在我的 Mac 上第一次安装了 Python 3.8,并且import sslimport _ssl 直接开箱即用! - 我建议您检查这些导入是否适用于您尝试使用的 Python 版本。如果没有,也许您应该重新安装该版本或使用并可能安装另一个版本。
  • 我使用Homebrew 安装了 3.8 和 3.9。我可以用 Homebrew 安装任何东西。它从来没有让我失望过。我不知道为什么这些包在或不在任何特定版本的 Python 中。事实上,我不能 100% 确定我的系统没有选择我以某种方式在全球范围内安装的 ssl 库的一个版本。然而,我的经验是,每个 Python 安装在模块方面都是独立的。如果这是真的,那么我的 3.9 肯定带有这些模块,因为当这个问题出现时,我刚刚安装它并且还没有对它做任何事情。
  • 我使用pyenv 来管理我所有的 Python 版本。如果您需要有关该工具的任何信息或帮助,我已经通过一些痛苦想出了一些关于它的事情,并且很乐意帮助您避免同样的事情。

标签: python macos jupyter-notebook sage


【解决方案1】:

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

鼠尾草也可以在线使用

您当前的安装已下载 作为一个 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 (例如安装 通过自制)。

这应该可以实现这个目标:

$ 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

【讨论】:

  • 如果你使用的是 M1 macos,你应该将 .homebrew-build-env 的第一行从 'brew --prefix' 修改为 '/usr/local/Homebrew/bin/brew --prefix ' 使用 x64_64 而不是 arm64 中的所有内容
  • 谢谢!我接受了最后一个建议(在使用自制软件安装 sage 之后)。我已经尝试这样做了好几个小时,这是唯一对我有用的东西。
猜你喜欢
  • 2022-01-09
  • 2021-07-25
  • 2021-09-07
  • 2021-06-08
  • 2022-01-14
  • 2021-03-01
  • 2021-09-04
  • 2021-11-26
  • 2020-10-20
相关资源
最近更新 更多