'How to add SageMath 9.4 kernel in Jupyter notebook

enter image description here

enter image description here

I have installed SageMath 9.4, but I could not lunch it in my terminal. When I type sage it said zsh: command not found: sage then I tried

alias sage='/Applications/SageMath-9-4.app'

and type sage again it said

zsh: permission denied: /Applications/SageMath-9-4.app

next I tried to add permission on that SageMath file. I cd to Applications file and type

chmod +x ./SageMath-9-4.app

Nothing happened.

I tried these to add sage in my Jupyter notebook directly

sudo jupyter kernelspec install /Applications/SageMath-9-4.app

jupyter kernelspec install --user /Applications/SageMath-9-4.app

They didn't work.

by the way:

jupyter kernelspec list
Available kernels:
  python3    /Applications/anaconda3/share/jupyter/kernels/python3

I googled these operations, but they didn't work on me. what should I do?

I want to lunch Sage in terminal when I type sage and I want to select kernel whenever I use Jupyter notebook.

The only way I can lunch SageMath is double click the App icon, and there will be a pop-out window enter image description here



Solution 1:[1]

Here is how I got it on MacOS with SageMath 9.5 mac app install from homebrew.

(base) ?  ~ sage -sh -c 'ls -d $SAGE_VENV/share/jupyter/kernels/python3'
/private/var/tmp/sage-9.5-current/local/var/lib/sage/venv-python3.9.9/share/jupyter/kernels/python3
(base) ?  ~ jupyter kernelspec install --user $(sage -sh -c 'ls -d $SAGE_VENV/share/jupyter/kernels/python3')
[InstallKernelSpec] Installed kernelspec python3 in /Users/XXXXXX/Library/Jupyter/kernels/python3
(base) ?  ~ jupyter lab

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Leo