millejoh / emacs-ipython-notebook

Jupyter notebook client in Emacs
http://millejoh.github.io/emacs-ipython-notebook/
GNU General Public License v3.0
1.47k stars 122 forks source link

Add support for Wolfram Language / Mathematica for Jupyter #589

Closed entropy43 closed 5 years ago

entropy43 commented 5 years ago

Wolfram has recently made a pretty cool Jupyter integration which permits a user to have a fairly full-featured interface with the Wolfram Language via Jupyter notebook.

The typical use case here is that this solution allows one to host their Wolfram / Mathematica kernels on a remote machine (ie on AWS / GCP etc) and then connect a Jupyter notebook via the usual methods instead of a "regular" Wolfram notebook.

As this is a live feature for regular Jupyter notebooks (though not lab -- yet) it would be great to have support for WolfLang / Mathematica in EIN.

I'd love to be able to contribute to this effort but not sure where to start?

How can we get this going?

dickmao commented 5 years ago

I would try following directions here, then here.

entropy43 commented 5 years ago

Thanks @dickmao

I have already successfully installed the Kernel and it is already accessible (and usable) as per those links via a regular jupyter notebook:

image

It is also visible to EIN:

image

But when I try to start a new notebook, I get the error

ein: [error] ein:ml-lang-setup: kernelspec language ’Wolfram-Language’ unsupported

My issue is how can we add Wolfram Language to the "quiver" of supported languages in EIN (given EIN can already see the installed Wolfram Kernel)

In terms of language support, emacs already has wolfram-mode to assist with syntax highlighting, ac etc.

It's really just a case of how we support the kernel inside EIN. Thoughts @millejoh ?

Also ccing Wolfram engineer @arnoudbuzing who often keeps a helpful eye on such efforts

dickmao commented 5 years ago

Good, now you need to turn on polymode as explained in the README.

entropy43 commented 5 years ago

Thanks -- this permits opening a notebook

image

but then get this error:

Warning (ein): pm:get-span: no major mode for kernelspec language 'Wolfram-Language

And, irrespective of whether any input is entered, the Kernel then dies

image

dickmao commented 5 years ago

We're in partially charted waters at this point. The kernel requiring reconnect looks bad.

If you haven't installed kawabata/wolfram-mode, that's required for this to work.

We've gotten julia notebooks to work under polymode without having to hardcode anything. Wolfram may have quirks that require tweaking. It's doable by someone like me, but could be quite painful for you.

dickmao commented 5 years ago

A fellow @fedeinthemix hardcoded wolfram in #545 . I frown upon such hardcoding, but that may be the only viable route as polymode may require expert fiddling.

entropy43 commented 5 years ago

Ok, the good news is that this "works"

image

The bad news is that it throws a language kernelspec warning every character you type:

image

I'm assuming that there's probably a relatively simple fix to link wolfram-mode to be the major mode in this case?

I really appreciate your help on this, @dickmao !

dickmao commented 5 years ago

Yes, try adding this to your .emacs or init.el:

(add-to-list 'auto-mode-alist '("\\.Wolfram-Language$" . wolfram-mode))
entropy43 commented 5 years ago

Ahh, perfect.... this works a treat:

image

Thank you so much, @dickmao ! Super helpful. I will mark this as closed for now.

tangw commented 3 years ago

@entropy43 Would you mind if I ask how you got the inline image shown properly in the wolfram mode?

PS: I've followed the instructions to turn on ein:output-area-inlined-images and setup mailcap-user-mime-data. I've also tried an example plot in Python and R kernel, respectively, and they both worked.