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

github.com/burakbayramli/kod/blob/master/site-lisp/pytexipy-notebook.py

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,

2
  • Before you get too far, have you seen Emacs IPython Notebook? It sounds a lot like what you're planning to do. Commented Nov 30, 2013 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.. Commented Dec 1, 2013 at 10:50

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.