15

is there a way I can link in jupyter notebooks (ipython) into the org-mode notebook? The same way other files (images) can be brought in? If it is possible will the outputs are also seen in the note (and inputs are runnable?), or only code itself? A dummy's guide would be a lot more appreciated as I'm new to emacs and configuring things are not straightforward.

I spend most of my time in Jupyter notebooks and try to document the various steps as a tutorial for colleagues who may want to reproduce my methods (sometimes code snippets are included) as well as discussing the findings in org-mode notebook. It's purely because org-mode notebook has much nicer interface with automatic sections/subsections and easily accessible for anyone (e.g. HTML). If someone wanted to check sensitivity of some other parameters, it would've been much nicer to have the ability to change the code within org-mode (without the need to switch to Jupyter) and output figures are automatically generated (same as Jupyter) or any other outputs. A lot of the times, I have to export various charts from Jupyter to be able to bring into org-mode. I was hoping whether I can switch to org-mode entirely and do all the coding in there. So there is an element of collaboration with colleagues who don't code and efficiency for myself so I can focus most of my time on emacs.

An example jupyter notebook with lots of outputs and graphs is given here, you would need to install seaborn as it doesn't come as a standard package if Anaconda is used.

Trey
  • 865
  • 5
  • 20
Curtis
  • 251
  • 2
  • 4
  • I am not sure what it is you are trying to do? Ipython saves its notebooks as ipynb, this is just a json so it should be straight forward to write a parser to convert it into an org txt file. I'm not sure if they exist already. On the other hand, if you would like to stay in emacs and in org mode then there is the emacs package og-ipython. This enables you to use the src blocks in org mode to interact with an ipython kernel, run code, output plots all within emacs. This is what I use mostly because I refuse to leave emacs! Hope this helps. https://github.com/gregsexton/ob-ipython – Seeralan S Jan 11 '19 at 12:07
  • 1
    John Kitchen has written ox-ipynb which appears to do something like that. I have not used it, but it might be worth trying. http://kitchingroup.cheme.cmu.edu/blog/2017/01/21/Exporting-org-mode-to-Jupyter-notebooks/ And because you're new, it's worth mentioning the tutorial, `C-h t` and, if you're inclined, the Introduction to Emacs Lisp is an excellent read: https://www.gnu.org/software/emacs/manual/eintr.html – Lorem Ipsum Jan 11 '19 at 13:09
  • I’m happy to write a tutorial to do this in order to help others do Reproducible Research! Would you update your question with some simple use case examples and a workflow. For example, do you want to pull ipynp files into org-mode? Generate ipynp files from org-mode? Both? Neither? How you update your question should include the answer to why you want to do this. For example, collaboration with others that don’t use emacs + org-mode. Best wishes! – Melioratus Jan 11 '19 at 18:43
  • Thanks for all your comments. @Melioratus - updated use keys as requested. – Curtis Jan 13 '19 at 14:41
  • Thank you! Your updates are very helpful! Writing this tutorial will be a fun learning experience for me! Do you have a Jupyter notebook with some graphs which I can use use for a reference for creating an org-mode file with similar functionality. A link to an example Jupyter notebook would be helpful to limit the scope of the tutorial. – Melioratus Jan 13 '19 at 17:08
  • The Jupyter notebook only needs enough detail so the answer can provide an apples to apples comparison. For example, [this question](https://emacs.stackexchange.com/q/46017/388) provided links to LaTeX templates which I used as a reference. – Melioratus Jan 13 '19 at 17:20
  • I have included an example jupyter notebook which has lots of graphs (in various sizes) and outputs. Thanks! – Curtis Jan 15 '19 at 10:43

2 Answers2

9

Nathaniel Nicandro has recently released his emacs package jupyter to further integrate org-mode with jupyter. As mentioned in the readme:

emacs-jupyter extends the features of ob-ipython by integrating more with org-mode and providing a better REPL interface to the kernel.

prash
  • 200
  • 1
  • 6
  • This is a better answer, I think, than ob-ipython, for the reasons I mention in my comment to @user3496846. – Trey Apr 11 '19 at 17:37
2

Check out ob-ipython: An Emacs library that allows Org mode to evaluate code blocks using a Jupyter kernel (Python by default), it might be what you are looking for. Run code on remote ipython kernels with Emacs and orgmode provides a basic example using exactly that library, and there are more related articles on that site as well.

user3496846
  • 378
  • 1
  • 10
  • 1
    See also https://github.com/dzop/emacs-jupyter#how-does-this-package-compare-to-other-similar-packages as mentioned in @prash's answer below. Especially as development seems to have halted on ob-ipython (at least as visible from GitHub), and Nathaniel Nicandro has been updating the version of ob-ipython code used in emacs-jupyter, it seems to be the natural successor, so probably the better answer in this case. The [README.org](https://github.com/dzop/emacs-jupyter/blob/master/README.org) alone should show you what it can do, it's rather impressive! – Trey Apr 11 '19 at 17:35
  • @Trey I wasn't aware of this one, thanks for the heads up! – user3496846 Apr 13 '19 at 06:48