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 123 forks source link

ein: [warn] ein:cell-append-mime-type: :image/png not supported #849

Closed shiso-five closed 2 years ago

shiso-five commented 2 years ago

Ein does not show figures when plt.plot() or plt.show() and the warning is shown as this issue title in emacs mini buffer. I toggled "on" at "M-x customize-group RET ein 'Ein Output Area Inline Images'", and wrote ~/.mailcap file as follows. image/*; open -a Preview "%s"

What should I do?

My python code is

#!/usr/bin/env python
# coding: utf-8

# In[3]:

get_ipython().run_line_magic('matplotlib', 'inline')

# In[4]:

import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2*np.pi, 500)

# In[5]:

plt.plot(x,np.sin(x))

My laptop environment is ・macOS Monterey 12.2.1 M1 chip ・emacs --version GNU Emacs 27.2

dickmao commented 2 years ago

Your curation of ~/.mailcap configures the external viewer, but toggling "on" Ein Output Area Inline Images contradicts this -- "inlining images in the output area" means "show up directly in emacs (don't use an external viewer)".

As for the warning, it sounds as if perhaps your emacs isn't built with basic image libraries. Verify this returns nil.

M-: (image-type-available-p (intern-soft (ein:cell-extract-image-format :image/png)))

shiso-five commented 2 years ago

OK. I executed M-: (image-type-available-p (intern-soft (ein:cell-extract-image-format :image/png))) and it returned nil.

shiso-five commented 2 years ago

Sorry I mistook × toggled "on" -> toggled "off"

shiso-five commented 2 years ago

The external viewer worked!

  1. I uninstalled emacs by brew uninstall emacs
  2. I reinstall by source compile of emacs 28.1