In Scimax, when I evaluate a pandas DataFrame (DF) in an Ipython block,

#+BEGIN_SRC ipython
data = [
    ['a', 'foo', 'bar'],
    ['FOO', 'and', 'BAR']

It produces both a plain text representation of the DF as well as a pop-up html.

I was wondering how I could disable this web page pop-up and possibly replace it with an inline image of the DF?


This is a tricky issue. The formatting is controlled by functions that are set in ob-ipython-mime-formatters. The html formatting is controlled by ob-ipython-format-text/html. The issue is that the output is raw html, which is very inconvenient in an org-file, especially when it is very long.

ob-ipython-preview-html was an approach to put an overlay on the html blocks. How that is done is in ob-ipython-html-font-lock.

To get what you want, you should create a function like ob-ipython-format-text/html that would create a temp html file, run the html to image program, save it and put a link to the image that would show it. I have had mixed luck converting html to images. A reasonable alternative might be to just save the html to a file, and link to it.

Some ways to suppress the html output are:

Use :display text/plain in the src block header.

or write your own formatter like this:

(defun my-format-html (_file _value)

(setf (cdr (assoc 'text/html ob-ipython-mime-formatters)) 'my-format-html)

I am transitioning away from ob-ipython in scimax, and moving towards emacs-jupyter.

  • How can I find documentation on the functions \ variables you mention? I tried looking in the built in docs, and in ob-ipython.el, nothing there. Would it be simpler to just disable the html output altogether, and leave just plain text?
    – J.Doe
    Jul 30 at 18:16
  • If you type C-h v, and then the name of the variable, or C-h f and the name of the function, it will show you documentation on them. Jul 30 at 20:41
  • They are defined in scimax-org-babel-ipython-upstream.el. I updated the answer with some ways to disable it. Jul 30 at 20:48

I don't use Scimax.

I had a look at the codebase and I suspect that adding the following to your init.el will fix it:

(setq ob-ipython-preview-html nil)

  • Thanks @aadcg, but that didn't work. I tried evaluating it locally in the file as well as adding to init.el. Regarding the later, I'm not sure how Scimax is configured so it might be that this option is configured in a different file? But I'm guessing it should have worked after evaluating locally.
    – J.Doe
    Jul 29 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.