Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to use SageMath on macOS Big Sur?

I downloaded SageMath-9.2 on my mac, but every time I try to use the notebook

by running "sage -n jupyter" on my terminal

I get the following massage:

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).

And also I can't open the app either for some reason ..... every time I click on the app I get a small window saying :

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.

I hope for some help, its very important for me because I must use SageMath for my college project.. thanks in advance

like image 419
Safa Amasha Avatar asked Nov 14 '20 21:11

Safa Amasha


1 Answers

On macOS Big Sur, there are several ways to install SageMath

  • using Conda: https://doc.sagemath.org/html/en/installation/conda.html
  • building from source, using as many Homebrew packages as you can: https://doc.sagemath.org/html/en/installation/source.html
  • using CoCalc-Docker: https://github.com/sagemathinc/cocalc-docker

Sage can also be used online using

  • Binder
    • https://sage-package.readthedocs.io/en/latest/sage_package/thebe.html
    • https://opendreamkit.org/2018/07/23/live-online-slides-with-sagemath-jupyter-rise-binder/
    • https://github.com/sagemath/sage-binder-env
  • CoCalc: https://cocalc.com
  • SageCell: https://sagecell.sagemath.org

The installation you currently have was downloaded as a macOS app, which ships its own Python which lacks the SSL module (for licence reasons).

To repair it:

  • change to the Sage directory
  • optionally get the latest development version
  • set number of jobs to run in parallel
  • get rid of that Sage's Python
  • configure
  • optionally follow the brew install recommendations at the end of configure
  • make
$ 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

The other way to solve your problem is to use the SageMath Jupyter kernel provided by Sage with your system-wide Jupyter (eg as installed via Homebrew).

This should achieve that goal:

$ 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
like image 105
Samuel Lelièvre Avatar answered Sep 28 '22 07:09

Samuel Lelièvre