Giter Club home page Giter Club logo

ob-ipython's People

Contributors

acowley avatar ajsteven130 avatar cpbotha avatar dvzubarev avatar emperordali avatar fleimgruber avatar fuxialexander avatar garaud avatar gregsexton avatar ilysym avatar izahn avatar jackkamm avatar jamieforth avatar jkitchin avatar kakuaky avatar kozikow avatar millejoh avatar nnicandro avatar smartass101 avatar syohex avatar thorrr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ob-ipython's Issues

Output tables

When IPython renders tables, convert these to org tables. Outputting a data frame for example would be nice to get an org table.

virtualenv support

It would be great to be able to utilize an ipython install from a virtualenv.

Graphic not saved to disk

Just found ob-ipython and I'm thrilled to see improved IPython support in Org.

I'm working my way through the README and most things work as expected, but not the image example. The #+RESULTS: line shows a link to whatever filename I enter in the :file foo.png header command. But the file does not appear on disk nor does it display in the Org buffer.

I'm on OS X 10.10.3 and using a recent emacs from Homebrew.

Missing .json extension for the connection file

ERROR:tornado.application:Uncaught exception POST /execute/mysession (127.0.0.1) HTTPServerRequest(protocol='http', host='localhost:9988', method='POST', uri='/execute/mysession', version='HTTP/1.1', remote_ip='127.0.0.1', headers={'Accept-Encoding': 'gzip', 'Mime-Version': '1.0', 'Accept': '*/*', 'Content-Length': '60', 'Host': 'localhost:9988', 'User-Agent': 'URL/Emacs', 'Connection': 'keep-alive', 'Extension': 'Security/Digest Security/SSL'}) Traceback (most recent call last): File "c:\Users\Fradav\Documents\Dev\Python\Miniconda3\lib\site-packages\tornado\web.py", line 1369, in _stack_context_handle_exception raise_exc_info((type, value, traceback)) File "<string>", line 3, in raise_exc_info File "c:\Users\Fradav\Documents\Dev\Python\Miniconda3\lib\site-packages\tornado\web.py", line 1572, in wrapper result = method(self, *args, **kwargs) File "c:/Users/Fradav/AppData/Roaming/.emacs.d/elpa/ob-ipython-20150704.457/driver.py", line 71, in post c = get_client(name) File "c:/Users/Fradav/AppData/Roaming/.emacs.d/elpa/ob-ipython-20150704.457/driver.py", line 54, in get_client clients[name] = create_client(name) File "c:/Users/Fradav/AppData/Roaming/.emacs.d/elpa/ob-ipython-20150704.457/driver.py", line 42, in create_client cf = find_connection_file('emacs-' + name) File "c:\Users\Fradav\Documents\Dev\Python\Miniconda3\lib\site-packages\IPython\kernel\connect.py", line 224, in find_connection_file raise IOError("Could not find %r in %r" % (filename, security_dir)) OSError: Could not find 'emacs-mysession' in 'C:\\Users\\Fradav\\AppData\\Roaming\\.ipython\\profile_default\\security' ERROR:tornado.access:500 POST /execute/mysession (127.0.0.1) 17.60ms

Just add + '.json' there :
cf = find_connection_file('emacs-' + name)
and it works.

ob-ipython; emacs cannot find ipython

Hi,
I am running emacs on mac os. I have org mode installed and I am using python and ipython from mac ports. I added the relevant path to my .emacs file. I can also execute python code in org mode. However, I get the following message when trying to execute a code block

Searching for program: no such file or directory, ipython

I would be thankful for some help.

localhost error without debugging message

I got the following error when running ob-ipython.

Debugger entered--Lisp error: (error "localhost/9988 System error")
make-network-process(:name "localhost" :buffer #<buffer url-http-temp> :host "localhost" :service 9988 :nowait t)
open-network-stream("localhost" #<buffer url-http-temp> "localhost" 9988 :type plain :nowait t)
byte-code("\306\211��\n\307>\203$�\n\310=\203��\311�\312�\f
��\313\n\314\315\316\317"&�\202Y�\n\320=\2034�\321�\f
��$\202Y�\n\322=\203D�\323�\f
��$\202Y�\n\324=\203T�\325�\f
��$\202Y�\326\327��"��_\306\207" [coding-system-for-write coding-system-for-read gw-method name buffer host binary (tls ssl native) native plain open-network-stream :type :nowait featurep make-network-process (:nowait t) socks socks-open-network-stream telnet url-open-telnet rlogin url-open-rlogin error "Bad setting of url-gateway-method: %s" service url-gateway-method conn] 11)
url-open-stream("localhost" #<buffer *url-http-temp_> "localhost" 9988)
url-http-find-free-connection("localhost" 9988)
url-http([cl-struct-url "http" nil nil "localhost" 9988 "/execute/default" nil nil t nil t] #128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)")
url-retrieve-internal("http://localhost:9988/execute/default" #128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)" nil nil)
url-retrieve("http://localhost:9988/execute/default" #[128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)"] nil nil nil)
url-retrieve-synchronously("http://localhost:9988/execute/default")
ob-ipython--execute-request("%matplotlib inline\nimport matplotlib.pyplot as plt\nimport numpy as np" "default")
org-babel-execute:ipython("%matplotlib inline\nimport matplotlib.pyplot as plt\nimport numpy as np" ((:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "replace") (:hlines . "no") (:session) (:result-type . value) (:result-params "replace") (:rowname-names) (:colname-names)))
org-babel-execute-src-block(nil)
org-babel-execute-src-block-maybe()
org-babel-execute-maybe()
org-babel-execute-safely-maybe()
run-hook-with-args-until-success(org-babel-execute-safely-maybe)
org-ctrl-c-ctrl-c(nil)
call-interactively(org-ctrl-c-ctrl-c nil nil)
command-execute(org-ctrl-c-ctrl-c)

In emacs message buffer, I got
contacting host : localhost:9988
Entering debugger

No error output for ob-ipython-driver
No error output for ipython (jupyter console 4.0.3)

I run ubuntu 14.04 with emacs 24.5. I installed ob-ipython from MELPA and pointed the load path in emacs init file. I also have tornador installed.

The error message contains very little information. I searched around but could not find a thread for similar issue.

appreciate input.

Interactive graphics

Is there a way to have graphics not be inline, so that we can work with them interactively?

Working with ipython3

What is needed to make ob-ipython work with ipython3. I think i am quite close:

I made the following changes:

(defun ob-ipython--kernel-cmd (name)
  (-concat (list "ipython3" "kernel" (format "--IPKernelApp.connection_file=emacs-%s.json" name))
           ob-ipython-kernel-extra-args))

(defun ob-ipython--kernel-repl-cmd (name)
  (list "ipython3" "console" "--existing" (format "emacs-%s.json" name)))

(defun ob-ipython--create-driver ()
  (when (not (process-live-p (ob-ipython--get-driver-process)))
    (ob-ipython--create-process "ob-ipython-driver"
                                (list (locate-file (if (eq system-type 'windows-nt) "python.exe" "python3")
                                                   exec-path)
                                      ob-ipython-driver-path
                                      (number-to-string ob-ipython-driver-port)))
    ;; give driver a chance to bind to a port and start serving
    ;; requests. so horrible; so effective.
    (sleep-for 1)))

I also set the following file-local variables in a .org file where I want to use ipython3:


# Local Variables:
# org-babel-python-command: python3
# python-shell-interpreter: ipython3
# End:

When starting work on an ipython notebook, I get the warning:

Warning (python): Your `python-shell-interpreter' doesn't seem to support readline, yet `python-shell-completion-native' was t and "ipython3" is not part of the `python-shell-completion-native-disabled-interpreters' list.  Native completions have been disabled locally. 

Using this, ob-ipython is able to send start an ipython3 kernel and C-c C-c sends code to it. However, the results are not displayed in the :RESULTS text. However, I can attach to the running session using a console and inspect the variables and they are set based on the code in the org-mode file. What other changes are necessary to make this work with ipython3?

Exporting code to latex

When exporting to LaTeX ipython code blocks, only the results get exported, even though :exports both is explicitly included.

The following sample org file fails to output the ipython code, but outputs only the results:
'''

+LATEX_CLASS: article

  • tema 1
    some text and ipython code

    initialize ipython kernel

    #+BEGIN_SRC ipython :session :exports both
    acf_time = 10.45678
    #+END_SRC

+RESULTS:

  • tema 2
    more ipython text and code

    +name: ipython_acf

    +BEGIN_SRC ipython :session :exports both

    '{:.3f}'.format(acf_time)

    +END_SRC

  • tema 3
    and now python code

    +name: python_acf

    +BEGIN_SRC python :session :exports both

    '{:.3f}'.format(acf_time)

    +END_SRC

+RESULTS: python_acf

: 10.457

The acf time in ipython export is call_ipython_acf()

the acf time in python export is call_python_acf()
'''
The produced pdf is included below.
exportacion.pdf

Exporting to ipynb format

It would be super-handy to be able to round-trip an ipython org notebook to the .ipynb format used by ipython notebook.

Cannot capture stdout

#+begin_src ipython :session :results output
print "Hello, world!"
#+end_src python

Yields results in the ob-ipython-stout buffer but nothing in the #+RESULTS: section

Anyone else seeing this problem?

Thanks again.

TRAMP support

No idea what the flow here should be but hooking in to tramp would be cool.

Also see #53 #11

Add async evaluation

This looks very good but, to really be useful, it needs to be asynchronous with the kernel evaluation.

Using 'import time; time.sleep(10)' blocks for 10s.

Other solution to get rid of `Trying to parse HTTP response code in odd buffer`

I just pulled the recent repo and get the error "Trying to parse HTTP response code in odd buffer". After checked the Issue #22 and 33, I found I can solve the problem with (setq python-shell-interpreter "/usr/local/bin/python"). However, I take the courage to ask: if there is other solution instead of this? And here is the reason:

I use the Elpy mode for my python-mode and I really enjoy that. I set (elpy-use-ipython) to use ipython for Elpy. If I set the python-shell-interpreter to python, the ob-ipython will works fine but broke the Elpy workflow. Interesting thing is I did not have this problem with previous version of ob-ipython.

BTW, thanks @gregsexton for this great package. I used to use EIN before but not anymore since I found ob-ipython, I do prefer the Org-mode more. And if anyone can auto complete with company-mode from different source blocks under the same :session, could you kindly give me some info on your setup, as I still suffer the Issue 54.

Many thanks
Fanpeng

Some information might be helpful:

  1. emacs-version: "GNU Emacs 24.5.1 (x86_64-apple-darwin15.3.0, NS apple-appkit-1404.34)
    of 2016-02-26 on Jupiter"
  2. org-version: "8.3.4"
  3. ipython version: 4.2.0
  4. jupyter version: 4.1.0

Backtrace:
Debugger entered--Lisp error: (error "Trying to parse HTTP response code in odd buffer: *http localhost:9988*-340583") signal(error ("Trying to parse HTTP response code in odd buffer: *http localhost:9988*-340583")) error("Trying to parse HTTP response code in odd buffer: %s" " *http localhost:9988*-340583") url-http-parse-response() (>= (url-http-parse-response) 400) (if (>= (url-http-parse-response) 400) (ob-ipython--dump-error (buffer-string)) (goto-char url-http-end-of-headers) (let ((json-array-type (quote list))) (json-read))) (save-current-buffer (set-buffer (url-retrieve-synchronously (format "http://%s:%d/execute/%s" ob-ipython-driver-hostname ob-ipython-driver-port name))) (if (>= (url-http-parse-response) 400) (ob-ipython--dump-error (buffer-string)) (goto-char url-http-end-of-headers) (let ((json-array-type (quote list))) (json-read)))) (let ((url-request-data code) (url-request-method "POST")) (save-current-buffer (set-buffer (url-retrieve-synchronously (format "http://%s:%d/execute/%s" ob-ipython-driver-hostname ob-ipython-driver-port name))) (if (>= (url-http-parse-response) 400) (ob-ipython--dump-error (buffer-string)) (goto-char url-http-end-of-headers) (let ((json-array-type (quote list))) (json-read))))) ob-ipython--execute-request("%matplotlib inline\nimport matplotlib.pyplot as plt\nimport numpy as np" "example") (ob-ipython--eval (ob-ipython--execute-request (org-babel-expand-body:generic (encode-coding-string body (quote utf-8)) params (org-babel-variable-assignments:python params)) (ob-ipython--normalize-session session))) (let ((ret (ob-ipython--eval (ob-ipython--execute-request (org-babel-expand-body:generic (encode-coding-string body (quote utf-8)) params (org-babel-variable-assignments:python params)) (ob-ipython--normalize-session session))))) (if ret (progn (let ((result (cdr (assoc :result ret))) (output (cdr (assoc :output ret)))) (if (eq result-type (quote output)) output (ob-ipython--create-stdout-buffer output) (cond ((and file ...) (ob-ipython--write-base64-string file ...)) ((and file ...) (ob-ipython--write-string-to-file file ...)) (file (error "%s is currently an unsupported file extension." ...)) (t (cdr ...)))))))) (let* ((file (cdr (assoc :file params))) (session (cdr (assoc :session params))) (result-type (cdr (assoc :result-type params)))) (org-babel-ipython-initiate-session session params) (let ((ret (ob-ipython--eval (ob-ipython--execute-request (org-babel-expand-body:generic (encode-coding-string body ...) params (org-babel-variable-assignments:python params)) (ob-ipython--normalize-session session))))) (if ret (progn (let ((result (cdr ...)) (output (cdr ...))) (if (eq result-type (quote output)) output (ob-ipython--create-stdout-buffer output) (cond (... ...) (... ...) (file ...) (t ...)))))))) org-babel-execute:ipython("%matplotlib inline\nimport matplotlib.pyplot as plt\nimport numpy as np" ((:colname-names) (:rowname-names) (:result-params "replace") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "replace") (:hlines . "no") (:session . "example"))) funcall(org-babel-execute:ipython "%matplotlib inline\nimport matplotlib.pyplot as plt\nimport numpy as np" ((:colname-names) (:rowname-names) (:result-params "replace") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "replace") (:hlines . "no") (:session . "example"))) (let ((result (funcall cmd body params))) (if (and (eq (cdr (assoc :result-type params)) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result)) (setq result (let ((result (funcall cmd body params))) (if (and (eq (cdr (assoc :result-type params)) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result))) (if (member "none" result-params) (progn (funcall cmd body params) (message "result silenced") (setq result nil)) (setq result (let ((result (funcall cmd body params))) (if (and (eq (cdr (assoc :result-type params)) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result))) (if (cdr (assoc :file params)) (progn (if result (progn (let ((temp-file ...) (temp-buffer ...)) (unwind-protect (prog1 ... ...) (and ... ...))))) (setq result (cdr (assoc :file params))))) (if (cdr (assoc :post params)) (progn (let ((*this* (if (cdr ...) (org-babel-result-to-file ... ...) result))) (setq result (org-babel-ref-resolve (cdr (assoc :post params)))) (if (cdr (assoc :file params)) (progn (setq result-params (remove "file" result-params))))))) (org-babel-insert-result result result-params info new-hash lang)) (let* ((lang (nth 0 info)) (result-params (cdr (assoc :result-params params))) (body (let* ((c (nthcdr 1 info))) (setcar c (if (org-babel-noweb-p params :eval) (org-babel-expand-noweb-references info) (nth 1 info))))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-as-directory (expand-file-name dir))) default-directory)) (cmd (intern (concat "org-babel-execute:" lang))) result) (if (fboundp cmd) nil (error "No org-babel-execute function for %s!" lang)) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (if (member "none" result-params) (progn (funcall cmd body params) (message "result silenced") (setq result nil)) (setq result (let ((result (funcall cmd body params))) (if (and (eq (cdr ...) (quote value)) (or (member "vector" result-params) (member "table" result-params)) (not (listp result))) (list (list result)) result))) (if (cdr (assoc :file params)) (progn (if result (progn (let (... ...) (unwind-protect ... ...)))) (setq result (cdr (assoc :file params))))) (if (cdr (assoc :post params)) (progn (let ((*this* (if ... ... result))) (setq result (org-babel-ref-resolve (cdr ...))) (if (cdr (assoc :file params)) (progn (setq result-params ...)))))) (org-babel-insert-result result result-params info new-hash lang)) (run-hooks (quote org-babel-after-execute-hook)) result) (cond (cache-current-p (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (forward-line) (skip-chars-forward " ") (let ((result (org-babel-read-result))) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result))) ((org-babel-confirm-evaluate info) (let* ((lang (nth 0 info)) (result-params (cdr (assoc :result-params params))) (body (let* ((c ...)) (setcar c (if ... ... ...)))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir (file-name-as-directory ...)) default-directory)) (cmd (intern (concat "org-babel-execute:" lang))) result) (if (fboundp cmd) nil (error "No org-babel-execute function for %s!" lang)) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (if (member "none" result-params) (progn (funcall cmd body params) (message "result silenced") (setq result nil)) (setq result (let ((result ...)) (if (and ... ... ...) (list ...) result))) (if (cdr (assoc :file params)) (progn (if result (progn ...)) (setq result (cdr ...)))) (if (cdr (assoc :post params)) (progn (let (...) (setq result ...) (if ... ...)))) (org-babel-insert-result result result-params info new-hash lang)) (run-hooks (quote org-babel-after-execute-hook)) result))) (let* ((params (nth 2 info)) (cachep (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr (assoc :cache params))))) (new-hash (if cachep (progn (org-babel-sha1-hash info)))) (old-hash (if cachep (progn (org-babel-current-result-hash)))) (cache-current-p (and (not arg) new-hash (equal new-hash old-hash)))) (cond (cache-current-p (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (forward-line) (skip-chars-forward " ") (let ((result (org-babel-read-result))) (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result))) ((org-babel-confirm-evaluate info) (let* ((lang (nth 0 info)) (result-params (cdr (assoc :result-params params))) (body (let* (...) (setcar c ...))) (dir (cdr (assoc :dir params))) (default-directory (or (and dir ...) default-directory)) (cmd (intern (concat "org-babel-execute:" lang))) result) (if (fboundp cmd) nil (error "No org-babel-execute function for %s!" lang)) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) (if (member "none" result-params) (progn (funcall cmd body params) (message "result silenced") (setq result nil)) (setq result (let (...) (if ... ... result))) (if (cdr (assoc :file params)) (progn (if result ...) (setq result ...))) (if (cdr (assoc :post params)) (progn (let ... ... ...))) (org-babel-insert-result result result-params info new-hash lang)) (run-hooks (quote org-babel-after-execute-hook)) result)))) (progn (let* ((c (nthcdr 2 info))) (setcar c (org-babel-process-params (car c)))) (let* ((params (nth 2 info)) (cachep (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr (assoc :cache params))))) (new-hash (if cachep (progn (org-babel-sha1-hash info)))) (old-hash (if cachep (progn (org-babel-current-result-hash)))) (cache-current-p (and (not arg) new-hash (equal new-hash old-hash)))) (cond (cache-current-p (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (forward-line) (skip-chars-forward " ") (let ((result ...)) (message (replace-regexp-in-string "%" "%%" ...)) result))) ((org-babel-confirm-evaluate info) (let* ((lang (nth 0 info)) (result-params (cdr ...)) (body (let* ... ...)) (dir (cdr ...)) (default-directory (or ... default-directory)) (cmd (intern ...)) result) (if (fboundp cmd) nil (error "No org-babel-execute function for %s!" lang)) (message "executing %s code block%s..." (capitalize lang) (if (nth 4 info) (format " (%s)" ...) "")) (if (member "none" result-params) (progn (funcall cmd body params) (message "result silenced") (setq result nil)) (setq result (let ... ...)) (if (cdr ...) (progn ... ...)) (if (cdr ...) (progn ...)) (org-babel-insert-result result result-params info new-hash lang)) (run-hooks (quote org-babel-after-execute-hook)) result))))) (if (org-babel-check-evaluate info) (progn (let* ((c (nthcdr 2 info))) (setcar c (org-babel-process-params (car c)))) (let* ((params (nth 2 info)) (cachep (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr ...)))) (new-hash (if cachep (progn (org-babel-sha1-hash info)))) (old-hash (if cachep (progn (org-babel-current-result-hash)))) (cache-current-p (and (not arg) new-hash (equal new-hash old-hash)))) (cond (cache-current-p (save-excursion (goto-char (org-babel-where-is-src-block-result nil info)) (forward-line) (skip-chars-forward " ") (let (...) (message ...) result))) ((org-babel-confirm-evaluate info) (let* ((lang ...) (result-params ...) (body ...) (dir ...) (default-directory ...) (cmd ...) result) (if (fboundp cmd) nil (error "No org-babel-execute function for %s!" lang)) (message "executing %s code block%s..." (capitalize lang) (if ... ... "")) (if (member "none" result-params) (progn ... ... ...) (setq result ...) (if ... ...) (if ... ...) (org-babel-insert-result result result-params info new-hash lang)) (run-hooks (quote org-babel-after-execute-hook)) result)))))) (let* ((org-babel-current-src-block-location (or org-babel-current-src-block-location (nth 5 info) (org-babel-where-is-src-block-head))) (info (if info (copy-tree info) (org-babel-get-src-block-info)))) (let* ((c (nthcdr 2 info))) (setcar c (org-babel-merge-params (car c) params))) (if (org-babel-check-evaluate info) (progn (let* ((c (nthcdr 2 info))) (setcar c (org-babel-process-params (car c)))) (let* ((params (nth 2 info)) (cachep (and (not arg) (cdr ...) (string= "yes" ...))) (new-hash (if cachep (progn ...))) (old-hash (if cachep (progn ...))) (cache-current-p (and (not arg) new-hash (equal new-hash old-hash)))) (cond (cache-current-p (save-excursion (goto-char ...) (forward-line) (skip-chars-forward " ") (let ... ... result))) ((org-babel-confirm-evaluate info) (let* (... ... ... ... ... ... result) (if ... nil ...) (message "executing %s code block%s..." ... ...) (if ... ... ... ... ... ...) (run-hooks ...) result))))))) org-babel-execute-src-block(nil) (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg) t) (if (memq (org-element-type (org-element-context)) (quote (inline-src-block src-block))) (progn (org-babel-eval-wipe-error-buffer) (org-babel-execute-src-block current-prefix-arg) t) nil) org-babel-execute-src-block-maybe() (or (org-babel-execute-src-block-maybe) (org-babel-lob-execute-maybe)) org-babel-execute-maybe() (if org-babel-no-eval-on-ctrl-c-ctrl-c nil (org-babel-execute-maybe)) org-babel-execute-safely-maybe() run-hook-with-args-until-success(org-babel-execute-safely-maybe) (cond ((or (and (boundp (quote org-clock-overlays)) org-clock-overlays) org-occur-highlights) (and (boundp (quote org-clock-overlays)) (org-clock-remove-overlays)) (org-remove-occur-highlights) (message "Temporary highlights/overlays removed from current buffer")) ((and (local-variable-p (quote org-finish-function) (current-buffer)) (fboundp org-finish-function)) (funcall org-finish-function)) ((run-hook-with-args-until-success (quote org-ctrl-c-ctrl-c-hook))) (t (if (save-excursion (beginning-of-line) (looking-at "[ ]*$")) (or (run-hook-with-args-until-success (quote org-ctrl-c-ctrl-c-final-hook)) (user-error "C-c C-c can do nothing useful at this location")) (let* ((context (org-element-context)) (type (org-element-type context))) (cond ((eql type (quote link)) (setq context (org-element-property :parent context)) (setq type (org-element-type context))) ((memql type (quote ...)) (setq context (org-element-lineage context ...)))) (if (eq type (quote paragraph)) (progn (let (...) (if ... ...)))) (cond ((eql type (quote clock)) (org-clock-update-time-maybe)) ((eql type (quote dynamic-block)) (save-excursion (goto-char ...) (org-update-dblock))) ((eql type (quote footnote-definition)) (goto-char (org-element-property :post-affiliated context)) (call-interactively (quote org-footnote-action))) ((eql type (quote footnote-reference)) (call-interactively (quote org-footnote-action))) ((memql type (quote ...)) (save-excursion (goto-char ...) (call-interactively ...))) ((eql type (quote item)) (let* (... ... ... ... ... ...) (org-list-set-checkbox ... struct ...) (org-list-struct-fix-ind struct parents 2) (org-list-struct-fix-item-end struct) (org-list-struct-fix-bul struct prevs) (org-list-struct-fix-ind struct parents) (let ... ... ...))) ((eql type (quote keyword)) (let (... ...) (if ... ...) (let ... ... --rtn)) (message "Local setup has been refreshed")) ((eql type (quote plain-list)) (let* (... ... ... ... ... ...) (cond ... ...) (org-list-write-struct struct ... old-struct) (org-update-checkbox-count-maybe) (save-excursion ... ...))) ((memql type (quote ...)) (call-interactively (quote org-property-action))) ((memql type (quote ...)) (call-interactively (quote org-update-radio-target-regexp))) ((eql type (quote statistics-cookie)) (call-interactively (quote org-update-statistics-cookies))) ((memql type (quote ...)) (if (eq ... ...) (message "%s" ...) (let ... ...))) ((eql type (quote timestamp)) (org-timestamp-change 0 (quote day))) (t (or (run-hook-with-args-until-success ...) (user-error "C-c C-c can do nothing useful at this location")))))))) org-ctrl-c-ctrl-c(nil) call-interactively(org-ctrl-c-ctrl-c nil nil) command-execute(org-ctrl-c-ctrl-c)

No org-babel-execute function for ipython

Hi there,
I'm trying to set up ob-ipython under spacemacs.

I installed ipython3, python3-tornado, python3-zmq via sudo apt-get install

The packages dash, s, f and ob-ipython are loaded the spacemacs way:
(setq dotspacemacs-additional-packages '(dash s f ob-ipython)

By applying this way of loading packages in spacemacs no configuration will be associated with those packages. So either I have to create a private layer for ob-ipython in spacemacs or I can define the necessary configuration within dotspacemacs/user-config.

What do I have to configure or tell org-babel when I get the following message when I try to evaluate a SRC block?: No org-babel-execute function for ipython

We should be calling 'jupyter console' not 'ipython console'

When I try running C-c C-c for a source code block, I get Process Python not running.

I have found two ways around this:

  1. Run M-x run-python first.

  2. Switch the following in ob-ipython.el (a trick I got from a redditor on /r/emacs).

(defun ob-ipython--kernal-repl-cmd (ameE)
  (list "ipython" "console" "--existing" (format "emacs-%s.json" name)))

for

(defun ob-ipython--kernal-repl-cmd (ameE)
  (list "jupyter" "console" "--existing" (format "emacs-%s.json" name)))

Any idea why this works? Both solutions feel wrong because in 1) I have to run a command every time and 2) I have to modify the source code which ruins any chance of upgrading potentially.

Printing a file link other than to png and svg image

I sometimes produce data files and I am wondering if it's possible to print a link to them as a file path.
In python for example I can do

#+begin_src python :results file
return "a/file/path.here"
#+end_src

#+RESULTS:
[[file:a/file/path.here]]

Graphic problems - issue #12 is back

I am experiencing the the issue exactly as described in #12 with emacs 25 and or 8.3
with ob-python freshly installed from MELPA, version 20151010.307
I am running on Linux Mint 17.3 Rosa.

+BEGIN_SRC emacs-lisp

(emacs-version)

+END_SRC

+RESULTS:

: GNU Emacs 25.1.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.10.8)
: of 2016-02-19

+BEGIN_SRC emacs-lisp

(org-version)

+END_SRC

+RESULTS:

: 8.3.4

Window setup

Hi, this isn't exactly an issue, but:

How do you preserve your window-setup? mine jump around when I enter a source block, close it again, etc. etc.

thanks!
tnt

Trying to parse HTTP response code in odd buffer

I receive the following messages when trying to run IPython code blocks:

executing Ipython code block...
Making python-shell-interpreter local to *Python* while let-bound!
Making python-shell-interpreter-args local to *Python* while let-bound!
Sent python-shell-completion-setup-code
Sent python-ffap-setup-code
Sent python-eldoc-setup-code
Contacting host: localhost:9988
url-http-parse-response: Trying to parse HTTP response code in odd buffer:  *http localhost:9988*

I am on OSX and Emacs 24.5. Any ideas?

Support svg

Currently we only support png output. SVG would be nice.

Does IPython support SVG using %matplotlib inline?

Support using remote kernels

I usually have ipython notebook running on a remote server, which I then connect to over ssh using port forwarding. These are the commands I usually run.

ssh -L 8888:127.0.0.1:8888 myserver
ipython notebook --port 8888 --no-browser

Then, I open 127.0.0.1:8888 in the browser on my local machine. Is there an easy way to do this sort of workflow in ob-ipython?

Not working with IPython 4. and Jupyter

I recently upgraded my Ipython versions and when evaluating a codeblock the system would stand still trying to: Contacting host: localhost:9988

If I kill the process I can read in ob-ipython-oi-ipython-driver

/home/oscar/miniconda/envs/dev/lib/python2.7/site-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated. You should import from ipykernel or jupyter_client instead.
  "You should import from ipykernel or jupyter_client instead.", ShimWarning)
['/home/oscar/.emacs.d/elpa/ob-ipython-20150704.457/driver.py', '9988']

Which is not much information for me.
I change nevertheles IPython.kernel for jupyter_client. That did not improve things.
When evaluating a block, it gets stuck in the same step.

If I give the block a session name I do get to an error the ob-ipython-debug says

HTTP/1.1 500 Internal Server Error
Date: Sat, 22 Aug 2015 13:43:07 GMT
Content-Length: 93
Content-Type: text/html; charset=UTF-8
Server: TornadoServer/4.2.1

<html><title>500: Internal Server Error</title><body>500: Internal Server Error</body></html>

and ob-ipython-oi-ipython-driver

ERROR:tornado.application:Uncaught exception POST /execute/cars (::1)
HTTPServerRequest(protocol='http', host='localhost:9988', method='POST', uri='/execute/cars', version='HTTP/1.1', remote_ip='::1', headers={'Content-Length': '165', 'Accept-Encoding': 'gzip', 'Extension': 'Security/Digest Security/SSL', 'Connection': 'keep-alive', 'Accept': '*/*', 'User-Agent': 'URL/Emacs', 'Host': 'localhost:9988', 'Mime-Version': '1.0'})
Traceback (most recent call last):
  File "/home/oscar/miniconda/envs/dev/lib/python2.7/site-packages/tornado/web.py", line 1369, in _stack_context_handle_exception
    raise_exc_info((type, value, traceback))
  File "/home/oscar/miniconda/envs/dev/lib/python2.7/site-packages/tornado/web.py", line 1572, in wrapper
    result = method(self, *args, **kwargs)
  File "/home/oscar/.emacs.d/elpa/ob-ipython-20150704.457/driver.py", line 71, in post
    c = get_client(name)
  File "/home/oscar/.emacs.d/elpa/ob-ipython-20150704.457/driver.py", line 54, in get_client
    clients[name] = create_client(name)
  File "/home/oscar/.emacs.d/elpa/ob-ipython-20150704.457/driver.py", line 42, in create_client
    cf = find_connection_file('emacs-' + name)
  File "/home/oscar/miniconda/envs/dev/lib/python2.7/site-packages/ipykernel/connect.py", line 85, in find_connection_file
    return jupyter_client.find_connection_file(filename, path=['.', security_dir])
  File "/home/oscar/miniconda/envs/dev/lib/python2.7/site-packages/jupyter_client/connect.py", line 185, in find_connection_file
    raise IOError("Could not find %r in %r" % (filename, path))
IOError: Could not find u'emacs-cars' in ['.', u'/home/oscar/.ipython/profile_default/security']
ERROR:tornado.access:500 POST /execute/cars (::1) 3.85ms

conflict with elpy

;; init.el
;; ob-ipython won't work if the below threes lines are abled.
(elpy-enable)
(elpy-use-ipython)
(setq python-shell-interpreter "ipython")

"bad file descriptor, Python" when trying to execute code block

Installed manually (package doesn't seem to be on melpa yet?) - I'm on OSX Yosemite and emacs 24.5.1

I found that I had to (require 'ob-python) as well or I would get an error that org-babel-variable-assignments:python was not defined.

test.org file:

* top
#+BEGIN_SRC ipython :session mysession :exports both
  def foo(x):
      return x + 9

  [foo(x) + 7 for x in range(7)]
#+END_SRC

Hitting C-c C-c inside the source blocks results in:

*Messages* buffer:

executing Ipython code block...
Sent python-shell-completion-setup-code
Sent python-ffap-setup-code
Sent python-eldoc-setup-code
comint-send-string: Writing to process: bad file descriptor, Python

emacs hangs if python block is not executed

If I run just an ipython session (example I've used below), I get the following warning and emacs hangs

Warning (python): Your ‘python-shell-interpreter’ doesn’t seem to support readline, yet ‘python-shell-completion-native’ was t and "python" is not part of the ‘python-shell-completion-native-disabled-interpreters’ list.  Native completions have been disabled locally. 
#+BEGIN_SRC ipython :session mysession :exports both
  def foo(x):
      return x + 9

 [foo(x) + 7 for x in range(7)]
#+END_SRC

However, if I run a python session before that, I get the same warning but emacs doesn't hang and I get results.

#+begin_src python :results output :session
print "There are %d hours in a week." % (7*24)
2**10
#+end_src

#+RESULTS:
: Python 2.7.9 |Anaconda 2.1.0 (x86_64)| (default, Dec 15 2014, 10:37:34) 
: [GCC 4.2.1 (Apple Inc. build 5577)] on darwin
: Type "help", "copyright", "credits" or "license" for more information.
: Anaconda is brought to you by Continuum Analytics.
: Please check out: http://continuum.io/thanks and https://binstar.org
: There are 168 hours in a week.
: python.el: native completion setup loaded
: 1024


#+BEGIN_SRC ipython :session mysession :exports both
  def foo(x):
      return x + 9

 [foo(x) + 7 for x in range(7)]
#+END_SRC

#+RESULTS:
: [16, 17, 18, 19, 20, 21, 22]

Any idea what is going on here?

Edit - I also get the following message when it hangs : "Shell native completion is disabled, using fallback". I'm using Jupyter v4.0

Image resolution different from plt.show() and plt.savefig()

Hi,

I have a specified 'matplotlibrc' file with the same settings of plt.show() and plt.savefig(). But when I C-c C-c on the code block, the resulting image has a very low resolution that different from I directly run the python code outside the org file. How can I solve this, namely make the output image inside org mode the same as plt.same() and plt.savefig()? Thanks !

Updated: I put

import matplotlib
print(matplotlib.matplotlib_fname())

in the org code block, which gives

~/.matplotlib/matplotlibrc'

I think matplotlib is using the same config as which I run the python outside a org file.

ob-ipython-inspect causes tornado to throw "Internal server error"; json.decoder?

Since ipython/jupyter upgrade, ob-ipython-inspect causes "Internal server error". Traceback from the ob-ipython-client-driver buffer suggests a missing/non-escaped character in json.decoder?

Traceback (most recent call last):
  File "/home/anaconda3/lib/python3.5/site-packages/tornado/web.py", line 1401, in _stack_context_handle_exception
    raise_exc_info((type, value, traceback))
  File "<string>", line 3, in raise_exc_info
  File "/home/anaconda3/lib/python3.5/site-packages/tornado/web.py", line 1603, in wrapper
    result = method(self, *args, **kwargs)
  File "/home/.emacs.d/elpa/ob-ipython-20160424.1305/driver.py", line 104, in post
    req = json.loads(self.request.body.decode("utf-8"))
  File "/home/anaconda3/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/home/anaconda3/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/anaconda3/lib/python3.5/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 9 (char 8)
ERROR:tornado.access:500 POST /inspect/default (::1) 3.20ms

$ ipython --version
4.2.0

$ jupyter --version 
4.1.0

ob-ipython installed but no functions available

According to the ob-ipython menu in paradox's paradox-list-packages:

ob-ipython is an installed package.

     Status: Installed in `~/.emacs.d/elpa/ob-ipython-20151010.307/' (unsigned).
    Archive: n/a
    Version: 20151010.307
   Requires: s-1.9.0, dash-2.10.0, dash-functional-1.2.0, f-0.17.2, emacs-24
    Summary: org-babel functions for IPython evaluation
   Homepage: http://www.gregsexton.org
   Keywords: literate programming reproducible research 
    Other versions: 20151010.307 (melpa).

Still, when I use M-x no ob-ipython related functions show up. And when I begin typing ob-ipython in a elisp buffer, no functions show up. Furthermore, this happens: #35 . This must mean that the package is not properly installed in some way.

Where can I begin to debug this?

C-c-C-c for +BEGIN_SRC ipython does not work, but +BEGIN_SRC python does

When I try to run the example

#+BEGIN_SRC python :session mysession :exports both
  def foo(x):
      return x + 9

  [foo(x) + 7 for x in range(7)]
#+END_SRC

I get a no-org-babel-execute function for ipython .

However, changing from

#+BEGIN_SRC ipython ...

to

#+BEGIN_SRC python ...

makes it work.

Is this a documentation mistake? If not, how do I fix my no-org-babel-execute function for ipython error?

ipython v4.2.0 and ob-ipython seem not to play well

Hi,
it seems that command line parameters have changed. I get (cropped to the main information)

[TerminalIPythonApp] CRITICAL | Bad config encountered during initialization:
[TerminalIPythonApp] CRITICAL | Unrecognized flag: '--port'

Process client-driver exited abnormally with code 1

and

[TerminalIPythonApp] CRITICAL | Bad config encountered during initialization:
[TerminalIPythonApp] CRITICAL | Unrecognized flag: '--conn-file'

Process kernel-default exited abnormally with code 1

(which probably also results in Issue #59). It seems that some of the cli parameters have changed, as indicated here: https://github.com/ipython/ipython/wiki/Cookbook:-Connecting-to-a-remote-kernel-via-ssh

% jupyter --version
4.1.0
% ipython --version
4.2.0

No output was produced to write to a file.

I've just started to try to use ob-ipython. Overall I think it's very good, but I do have one problem with it. Namely, I can't reliably get the org file to export. For instance, just now I successfully exported to HTML, then tried to export to PDF and got:

No output was produced to write to a file.

I've appended the file I'm using.

I suspect that the problem may be that I'm not using org-mode correctly, as I hadn't used in it a long time prior to this experiment. Thoughts? Thanks.

+OPTIONS: toc:nil num:nil skip:nil ^:nil{}

+TITLE: Playing with ob-ipython

+AUTHOR:

+DATE:

+LATEX_HEADER: \addtolength{\oddsidemargin}{-.875in}

+LATEX_HEADER: \addtolength{\evensidemargin}{-.875in}

+LATEX_HEADER: \addtolength{\textwidth}{1.75in}

+LATEX_HEADER: \addtolength{\topmargin}{-.875in}

+LATEX_HEADER: \addtolength{\textheight}{1.75in}

+BEGIN_SRC ipython :session

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

+END_SRC

+begin_src ipython :session :exports both :results output :cache no

import time
print("Hello, today's date is %s" % time.ctime())
print("Two plus two is %d " % (2 + 2))

+end_src

+BEGIN_SRC ipython :session :exports both

animal = "otter"

+END_SRC

+RESULTS:

+BEGIN_SRC R :exports both :results output

x <-rnorm(100)
print(summary(x))

+END_SRC

+BEGIN_SRC ipython :session :exports both :results output

print("The animal is:\n")
print(animal)

+END_SRC

+BEGIN_SRC ipython :session :file /tmp/image.png :exports both

plt.hist(np.random.randn(20000), bins=200)

+END_SRC

Code block produced no output

When executing a code block I get:
Code block produced no output.
in the minibuffer and the results remain blank.

The code is evaluated, but no output is produced, I have tried the the examples and my own code blocks with a minimal configuration file.

Move toward ob-jupyter

We currently have :kernel support but this doesn't work across all features.

  • Seems you can only have one REPL and it's called Python. This then
    gets used to do autocomplete in python buffers. If it's not actually
    a python repl this causes all manner of failure.
  • Opening a src block opens it in python mode
  • You have to use the session arg to mix code. [I mentioned this in
    the README.]
  • Variables and tables don't work generically. Not sure how to fix this.
  • Rename to ob-jupyter

other backends?

Hi,

this seems to be an awesome package, but I'd really like to use it with the julia kernel instead. Do you plan to support alternative backends, or could you give me a brief overview which parts of your code I'd have to change to add this myself?
thanks,
Sebastian

Inline Math and Dark Background

Hello,

I use Emacs with a dark background. Inline matplotlib plots by default have white background which is OK. However, the tick labels and axes labels have black facecolor and are transparent. I.e., the facecolor and the backgroundcolor is dark and they are not readable. Is there a workaround, how I can change either the transparency of this region, or the facecolor?

Thanks,
Dominik

export to pdf: no lexer for alias 'ipython' found

Error:

  • message: no lexer for alias 'ipython' found
  • latex doesn't recongize ipython, changed to python, OK
    • Not work: #+BEGIN_SRC ipython :session :exports both
    • work: #+BEGIN_SRC python :session :exports both

The org file:

+TITLE: test ob-ipython to pdf

  • Hi, ob-ipython

+BEGIN_SRC ipython :session :exports both

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

+END_SRC

+RESULTS:

The generated tex file:

% Created 2016-05-10 Tue 12:02
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{amssymb}
\usepackage{hyperref}
\tolerance=1000
\usepackage{minted}
\author{gang}
\date{\today}
\title{test ob-ipython to pdf}
\hypersetup{
pdfkeywords={},
pdfsubject={},
pdfcreator={Emacs 24.4.1 (Org mode 8.2.10)}}
\begin{document}

\maketitle
\tableofcontents

\section{Hi, ob-ipython}
\label{sec-1}

\begin{minted}[mathescape=true,linenos=true,numbersep=5pt,frame=lines,framesep=2mm]{ipython}
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
\end{minted}
% Emacs 24.4.1 (Org mode 8.2.10)
\end{document}

Python Warnings upon Startup

Hello, when I execute a code block, I get the following warnings in my python session:

[TerminalIPythonApp] WARNING | Subcommand `ipython console` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter console`... continue in 5 sec. Press Ctrl-C to quit now.

Auto complete not working in another code block under the same session

I tried the code as shown in the example document. I first import matplotlib.pyplot and numpy in the first session code block In the org-mode ipython mode buffer for this code block, I can get auto complete after I do np. or plt. However when I started another code block under the same session, the auto complete no longer works. It was clearly shown working in the screenshot provided by @gregsexton, so I wonder if anyone has the same problem and could give me some suggestions? Thanks in advance

Some information:
I use Elpy for the python mode, which use company mode for auto completion.

Update link to EIN to https://github.com/millejoh/emacs-ipython-notebook

Yes, really. Sorry for being so picky, but you are linking to the 'old' version of EIN. TKF did some amazing work, but his code has not been updated in a long time and only works with IPython 1.0 and earlier. I have taken his hard work and updated it to work with IPython 2.x and beyond.

Thanks - I am really looking forward to trying out ob-ipython. Your comment on org having better markup and organizing features is spot on, and something I wish I had the time to implement in EIN.

Trying to parse HTTP response code in odd buffer

Debugger entered--Lisp error: (error "Trying to parse HTTP response code in odd buffer:  *http localhost:9988*")
  signal(error ("Trying to parse HTTP response code in odd buffer:  *http localhost:9988*"))
  error("Trying to parse HTTP response code in odd buffer: %s" " *http localhost:9988*") ````

make client process fails on WIndows 7

Hello,

First, thanks for the awesome package. I am using Emacs 24.5 on Windows 7 with Python 3.4 and Ipython 3.1.0.

I installed ob-ipython from master (it does not appear to be on melpa yet), and I have all of the dependencies installed.

When running an ipython block, I get the following messages and no output:

executing Ipython code block...
Contacting host: localhost:9988
open-network-stream: make client process failed: connection refused, :name, localhost, :buffer, #, :host, localhost, :service, 9988, :nowait, nil

Executing does create a REPL buffer and a kernel buffer.

Edit - here is the backtrace from Emacs:

Debugger entered--Lisp error: (file-error "make client process failed" "connection refused" :name "localhost" :buffer #<buffer url-http-temp> :host "localhost" :service 9988 :nowait nil)
make-network-process(:name "localhost" :buffer #<buffer url-http-temp> :host "localhost" :service 9988 :nowait nil)
open-network-stream("localhost" #<buffer url-http-temp> "localhost" 9988 :type plain :nowait nil)
byte-code . . .
url-open-stream("localhost" #<buffer url-http-temp> "localhost" 9988)
url-http-find-free-connection("localhost" 9988)
url-http([cl-struct-url "http" nil nil "localhost" 9988 "/execute/default" nil nil t nil t] #128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)")
url-retrieve-internal("http://localhost:9988/execute/default" #128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)" nil nil)
url-retrieve("http://localhost:9988/execute/default" #[128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)"] nil nil nil)
url-retrieve-synchronously("http://localhost:9988/execute/default")
(set-buffer (url-retrieve-synchronously (format "http://localhost:%d/execute/%s" ob-ipython-driver-port name)))
(save-current-buffer (set-buffer (url-retrieve-synchronously (format "http://localhost:%d/execute/%s" ob-ipython-driver-port name))) (if (>= (url-http-parse-response) 400) (ob-ipython--dump-error (buffer-string)) (goto-char url-http-end-of-headers) (let ((json-array-type (quote list))) (json-read))))
(let ((url-request-data code) (url-request-method "POST")) (save-current-buffer (set-buffer (url-retrieve-synchronously (format "http://localhost:%d/execute/%s" ob-ipython-driver-port name))) (if (>= (url-http-parse-response) 400) (ob-ipython--dump-error (buffer-string)) (goto-char url-http-end-of-headers) (let ((json-array-type (quote list))) (json-read)))))
ob-ipython--execute-request("from matplotlib import pyplot as plt\nimport numpy as np\nimport pandas as pd\n\n%matplotlib inline" "default")
(ob-ipython--eval (ob-ipython--execute-request (org-babel-expand-body:generic body params (org-babel-variable-assignments:python params)) (ob-ipython--normalize-session session)))
(let ((result (ob-ipython--eval (ob-ipython--execute-request (org-babel-expand-body:generic body params (org-babel-variable-assignments:python params)) (ob-ipython--normalize-session session))))) (if result (progn (cond ((and file (string= (f-ext file) "png")) (ob-ipython--write-base64-string file (cdr (assoc ... result)))) (file (error "%s is currently an unsupported file extension." (f-ext file))) (t (cdr (assoc (quote text/plain) result)))))))
(let* ((file (cdr (assoc :file params))) (session (cdr (assoc :session params)))) (org-babel-ipython-initiate-session session) (let ((result (ob-ipython--eval (ob-ipython--execute-request (org-babel-expand-body:generic body params (org-babel-variable-assignments:python params)) (ob-ipython--normalize-session session))))) (if result (progn (cond ((and file (string= ... "png")) (ob-ipython--write-base64-string file (cdr ...))) (file (error "%s is currently an unsupported file extension." (f-ext file))) (t (cdr (assoc ... result))))))))
org-babel-execute:ipython("from matplotlib import pyplot as plt\nimport numpy as np\nimport pandas as pd\n\n%matplotlib inline" ((:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "both") (:results . "file replace") (:hlines . "no") (:session) (:file . "./tmp/image.png") (:result-type . value) (:result-params "file" "replace") (:rowname-names) (:colname-names)))
org-babel-execute-src-block(nil)
org-babel-execute-src-block-maybe()
org-babel-execute-maybe()
org-babel-execute-safely-maybe()
run-hook-with-args-until-success(org-babel-execute-safely-maybe)
org-ctrl-c-ctrl-c(nil)
call-interactively(org-ctrl-c-ctrl-c nil nil)
command-execute(org-ctrl-c-ctrl-c)

interpreter python version 2 on linux

in melpa ob-ipython 20160305.843, opening ipython blocks in org-babel throws me into ipython with python 2 instead of python3.

python-mode opens correctly with anaconda ipython with python 3 after having set
(setq python-shell-interpreter "~/anaconda3/bin/ipython3")
, and ob-ipython connects to it when previously opened by python-mode manually.

I run on ubuntu with ipython and python installed; anaconda version is on my path (shell opens anaconda ipython by default).

I thought after Issue 32, python-shell-interpreter was used.

I tried adding any of these, but none change it:

  (setq python-shell-exec-path "~/anaconda3/bin")
  (setq python-shell-interpreter "~/anaconda3/bin/ipython3")
  (setq org-babel-python-command "~/anaconda3/bin/ipython3")

Am I overlooking something?

exporting of strings when converting org-mode file.

I'm trying to use the values stored in variables as strings in my floating text. My current approach
for this is.

#+name print_acf_val
#+begin_src ipython :session :exports none 
    '{:.3f}'.format(acf_time)
#+end_src

The acf time for this process is call_print_acf_val().

In latex that gets evaluated to

The acf time for this process is ='10.452'=

This is not very ideal to me because it looks ugly. I would ideally like that the latex output looks like

the acf time for this process is 10.452

In fact that is what happens when I use the normal python interpreter in org-mode

#+LATEX_CLASS: article

# initialize ipython kernel
#+BEGIN_SRC ipython :session :exports none
acf_time = 10.45678
#+END_SRC

#+name: ipython_acf
#+BEGIN_SRC ipython :session :exports none
'{:.3f}'.format(acf_time)
#+END_SRC

#+name: python_acf
#+BEGIN_SRC python :session :exports none
'{:.3f}'.format(acf_time)
#+END_SRC

The acf time in ipython export is call_ipython_acf()

the acf time in python export is call_python_acf()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.