Home > Software design >  org-mode inline images not working (remotely with TRAMP)
org-mode inline images not working (remotely with TRAMP)

Time:01-12

I am working with emacs org-mode on a remote machine using TRAMP. I connect code cells to a jupyter server (on that remote machine) where I start a python 3 kernel. Code execution works perfectly fine, I can also create plots with matplotlib. While a .png is generated in the right temp file location, the output of the code cell is a (relative) link to the file without displaying it inline as expected.

An example code-block look like this:

# BEGIN_SRC jupyter-python :session /jpy:localhost#9090:TEST
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(range(10), range(10))
# END_SRC
# RESULTS:
:RESULTS:
| <matplotlib.lines.Line2D | at | 0x7f1c43a289a0> |
[[file:./.ob-jupyter/e1eecf5d59de9bfa1d3468867a64aadf4b1a6261.png]]
:END:

C-c C-x C-v gives the message: 'No images to display inline'

C-c o opens and displays the file in a different buffer correctly.

I would expect the file to display correctly inline in the org-mode buffer.

I tried to change the link manually to a TRAMP path, looking something like this:

[[file:/ssh:MYSERVER:/PATH_TO_TEMP_FOLDER/.ob-jupyter/e1eecf5d59de9bfa1d3468867a64aadf4b1a6261.png]]

which also allows me to open the file with C-c o, but won't display the file inline (Same behavior as described above)

If I open the jupyter-repl session directly and type fig (after executing the above code block) The figure displays as expected in the jupyter-repl buffer

If I run the jupyter session locally, inline plotting works as expected


Update:

I realized if I C-f on the link to open the file, the link expands to an invalid tramp link, which throws the following error message:

File is missing: /ssh:bih:/PATH_TO_CORRECT_FOLDER/00_test/file:./.ob-jupyter/

Note the file:./ at the end of the link that doesn't belong there. So I think something is going wrong somewhere between TRAMP and org-mode (or emacs-jupyter). Any ideas how to fix this?

CodePudding user response:

C-h v org-display-remote-inline-images says:

org-display-remote-inline-images is a variable defined in ‘org.el’.

Its value is ‘skip’

How to display remote inline images.
Possible values of this option are:

skip        Don’t display remote images.
download    Always download and display remote images.
cache       Display remote images, and open them in separate buffers
            for caching.  Silently update the image buffer when a file
            change is detected.

Check the value and maybe customize the variable to do something other than skip.

  • Related