2

I am a new Emacs user and proceeded to the install following the tutorial at: https://realpython.com/emacs-the-best-python-editor/#integration-with-jupyter-and-ipython. Now I am running a Jupyter Notebook, again as described in the link above, but I am getting the following error:

 ein:cel--append-mime-type no viewer found in mailcap

Do you have any idea what I should do? I tried to solve it using https://github.com/millejoh/emacs-ipython-notebook/issues/671 but couldn't find the recommended fix (customize-group-ein-image on) to run.

import matplotlib
import matplotlib.pyplot as plt
import numpy as np

# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)

fig, ax = plt.subplots()
ax.plot(t, s)

ax.set(xlabel='time (s)', ylabel='voltage (mV)',
       title='About as simple as it gets, folks')
ax.grid()
plt.show()

For information, I am running Emacs on Windows 10

Drew
  • 75,699
  • 9
  • 109
  • 225
Nre
  • 143
  • 5

1 Answers1

1
  • You should M-x customize RET and look for "mailcap mime".
  • Navigate to "Mailcap User Mime Data".
  • INS new entry.
  • Clock in Choice:Value Menu and choose Shell command.
  • type in Choice Shell command: sxiv %s
  • type in MIME Type: image/*

Save the customization. Now, when jupyter looks for how to visualize an image file it will use sxiv. As the procedure we would like to emulate is upon a string-directory, the format is sxiv %s(tring). Just like we would type in a terminal to visualize an image with sxiv, e.g., sxiv ~/path/to/my/image. The path is provided by a temporary file created by jupyter as the output of the cell.

I hope it's clear.

ALTERNATIVE (tested): in $HOME/.mailcap file, put the following text and save it:

image/*; magick display %s

In Emacs, M-x customize RET, look for ein inline images, and Toggle to on (non-nil) the Ein Output Area Inlined Images: area.

Ein Output Area Inlined Images: Toggle  on (non-nil)
    State : SET for current session only.
   Turn on to insert images into buffer.  Default spawns external viewer.
Groups: Ein

If you have imagemagick installed (an image viewer and manipulator), you should be able to go to an ein-jupyter session, in a jupyter notebook, and see images inlined: enter image description here

EDIT: include author MWE Your example works fine here, after this setup. enter image description here

NOTES:

  • You can use whatever image viewer software you would like, sxiv,imagemagick, gimp, etc.
BuddhiLW
  • 257
  • 1
  • 7