0

I want to duplicate ipython notebook capability in Emacs / Pymacs; and I need some direction for a simple code that can 1) send python / "magics" code to a ipython kernel 2) receive the display output, as a string. I found this comment by minrk, the "ipython kernel" example did not work, it gave "ImportError: No module named zmq.blockingkernelmanager".

I had better luck with one his other pointers, finally I landed at ipython-1.1.0/IPython/kernel/inprocess/tests/test_kernel.py, I ripped out a minimal part, and coded an Emacs extension called pytexipy-notebook. It's on Github

goo.gl/kQzJW1

If anyone knows of better examples, such as connecting to an existing (out of process), I'd like to hear about these.

Thanks in advance,

BBSysDyn
  • 4,389
  • 8
  • 48
  • 63
  • Before you get too far, have you seen [Emacs IPython Notebook](http://tkf.github.io/emacs-ipython-notebook/)? It sounds a lot like what you're planning to do. – Thomas K Nov 30 '13 at 20:28
  • I use Ein myself; I guess I could rip out its code that can connect and pass python code to kernel, I just wanted to do my coding in pure python. :) Getting into Ein elisp seemed like a lot of trouble.. – BBSysDyn Dec 01 '13 at 10:50

1 Answers1

1

Here is a sample for ipython 3.0.

from IPython.testing.globalipapp import get_ipython
from IPython.utils.io import capture_output
ip = get_ipython()

def run_cell(cmd):
    with capture_output() as io:
        res = ip.run_cell(content)
        print 'suc', res.success
        print 'res', res.result
    res_out = io.stdout
    print 'res out', res_out

content = "print (111+222)"
run_cell(content)
content = "alsdkjflajksf"
run_cell(content)

I will soon update

https://github.com/burakbayramli/emacs-ipython

BBSysDyn
  • 4,389
  • 8
  • 48
  • 63