Setting up Jupyter for Macaulay2

575 views
Skip to first unread message

Annie Giokas

unread,
Jan 20, 2022, 8:31:59 PM1/20/22
to Macaulay2
Hi everyone, 

I tried using Jupyter for Macaulay2 last year and it was really useful for presentations and making notes. 

Here are the instructions, tell me if it works for you:

Installing Jupyter

Install Anaconda on wsl which will manage python versions and jupyter. This is recommended since this will allow the browser to work correctly since using jupyter separately caused some issues when using the browser, such as notebook files not opening. You can install anacdonda by following the instructions here: https://mas-dse.github.io/startup/anaconda-ubuntu-install/ or here: https://docs.anaconda.com/anaconda/install/linux/ https://jupyter.org/install

After you install anacdonda on wsl server:

conda install -c conda-forge notebook

Update your package manager:

$ sudo apt update

Then install pip3:

$ sudo apt install python3-pip

Install jupyter using apt again:

$ sudo apt install jupyter

Now we need to install the Macaulay2 kernel for jupter to recodnize the Macaulay2 code and make notebooks using that kernel available. Make sure you run this as root (Add sudo at the beginning), because it tries to put files in system diretories:

$ sudo pip3 install macaulay2-jupyter-kernel $ sudo python3 -m m2_kernel.install

Then to make a new notebook, type:

$ jupyter notebook

If you fixed the browser to work on wsl, it should redirect you to your chosen browser in Windows. Then you should be able to make an M2 file in jupyter.

You can also try using the VS code extension for jupyter: https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter

Youngsu

unread,
Mar 27, 2022, 2:37:38 PM3/27/22
to Macaulay2
Thank you for the information. I could add the kernel, but I get the "KERNEL ENFORCED TIMEOUT" message for some "large" computations. Do you know how to resolve this?

o8 = [KERNEL ENFORCED TIMEOUT]

It only happens in the JupyterLab/Notebook, but not in the terminal. 

Neil Ramsamooj

unread,
Dec 28, 2023, 8:13:27 AM12/28/23
to Macaulay2
From the following picture from the demo, it seems that timeout can be set:
Screenshot 2023-12-28 022732.png

Youngsu

unread,
Jan 17, 2024, 12:52:25 AMJan 17
to Macaulay2
Thank you for pointing it out. The JupyterKernel is implemented by https://github.com/rz-c/Macaulay2-Jupyter-Kernel/. I tried to contact the author and ended up modifying the package myself. I wish I had known this magic. 

Thank you

Reply all
Reply to author
Forward
0 new messages