Reputation: 1265
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. Many Thanks
Upvotes: 2
Views: 2072
Reputation: 824
You can use ipython
in an org babel
code block.
1) start in a shell jupyter-console
2) copy the json filename from /run/user/1000/jupyter
to :session
argument in the source code header.
an example:
#+BEGIN_SRC ipython :session kernel-9735.json :exports both :results raw drawer
import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
import numpy as np
fig = plt.figure()
ax = plt.axes()
x = np.linspace(0, 10, 1000)
ax.plot(x, np.sin(x));
#+END_SRC
for plot image output M-x org-display-inlineimages
you will need to add ipython to your org-babel: (require 'ob-ipython)
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)
(ipython . t)))
and generally:
(setq org-src-fontify-natively t
org-src-preserve-indentation t
org-src-tab-acts-natively t)
I found that ipython is no longer using readline
so it causes some strange formatting, this is solved using:
(setq org-babel-python-command "/PATH/TO/FOO/BAR/BAZ/ipython3 --no-banner --classic --no-confirm-exit")
for inline images:
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images 'append)
I recommend to check out scimax which is an Emacs starterkit for scientists and engineers. and ein which works a treat!
Upvotes: 4