From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ken Mankoff Subject: Re: python :session does return Date: Thu, 16 Jan 2014 15:14:29 -0500 (EST) Message-ID: References: Reply-To: Ken Mankoff Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3tKp-0003jm-5r for emacs-orgmode@gnu.org; Thu, 16 Jan 2014 15:14:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W3tKj-00070o-VL for emacs-orgmode@gnu.org; Thu, 16 Jan 2014 15:14:39 -0500 Received: from mail-qa0-x231.google.com ([2607:f8b0:400d:c00::231]:52277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3tKj-00070a-M6 for emacs-orgmode@gnu.org; Thu, 16 Jan 2014 15:14:33 -0500 Received: by mail-qa0-f49.google.com with SMTP id w8so2505074qac.22 for ; Thu, 16 Jan 2014 12:14:32 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: John Hendy Cc: Org-mode Hi John, On Wed, 15 Jan 2014, John Hendy wrote: > On Wed, Jan 15, 2014 at 6:22 AM, Ken Mankoff wrote: > Are my results contrary to what's been happening to you? Actually things now seem to be working. All cases. No hanging when I run Python in a session, and return and print work when running IPython. I wrote a test example, load it with emacs -q and then load a minimal org setup in a code block (I think I'm just starting to get the hang of some basic lisp and tangling code in Org). I've tried all possible cases (yes/no session, and results of default/output/value) and it all seems to be working. I then repeated it all with IPython instead of default Python. Output results are a bit ugly when using IPython. If I get a chance I'll look into the code. Since regular python output doesn't print the startup info, I assume the same can be done for IPython. It should just ignore everything until the first "In [1]:" text appears. Perhaps the previous issues were due to a complicated org setup. Test file follows. Cheers, -k. * Intro This is a test file for Python + Emacs. I'm loading this file running "emacs -q test.org" to try to simplify the setup ** Setup For running Python and other stuff #+BEGIN_SRC emacs-lisp (setq org-confirm-babel-evaluate nil) ;; don't ask to eval code (org-babel-do-load-languages 'org-babel-load-languages '((python . t) (sh . t) (emacs-lisp . t) )) #+END_SRC #+RESULTS: | (python . t) | (sh . t) | (emacs-lisp . t) | ** System setup: #+BEGIN_SRC sh :results output /usr/local/bin/emacs --version uname -a python -V # no ouput for some reason... # Python 2.7.3 -- 64-bit #+END_SRC #+RESULTS: : GNU Emacs 24.3.1 : Darwin 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; xnu-2422.1.72~6/RELEASE_X86_64 x86_64 * Testing There are two tests per :output and per :session option. 1. 'foo' equal to 'print foo' 2. 'print foo'. ** No Session **** No Session, No Results #+BEGIN_SRC python print 'No Session, No Result' #+END_SRC #+RESULTS: : None #+BEGIN_SRC python return 'No Session, No Result' #+END_SRC #+RESULTS: : No Session, No Result **** No Session, Result Output #+BEGIN_SRC python :results output print 'No Session, Result Output' #+END_SRC #+RESULTS: *Warning: Does not run* #+BEGIN_SRC python :results output return 'No Session, Result Output' #+END_SRC #+RESULTS: **** No Session, Result Value #+BEGIN_SRC python :results value print 'No Session, Result Value' #+END_SRC #+RESULTS: : None #+BEGIN_SRC python :results value return 'No Session, Result Value' #+END_SRC #+RESULTS: : No Session, Result Value ** Yes Session **** Yes Session, No Results #+BEGIN_SRC python :session foo print 'No Session, No Result' #+END_SRC #+RESULTS: : None #+BEGIN_SRC python :session foo return 'No Session, No Result' #+END_SRC #+RESULTS: : No Session, No Result **** Yes Session, Result Output #+BEGIN_SRC python :results output :session foo print 'No Session, Result Output' #+END_SRC #+RESULTS: *Warning: Does not run* #+BEGIN_SRC python :results output :session foo return 'No Session, Result Output' #+END_SRC #+RESULTS: **** Yes Session, Result Value #+BEGIN_SRC python :results value :session foo print 'No Session, Result Value' #+END_SRC #+RESULTS: : None #+BEGIN_SRC python :results value :session foo return 'No Session, Result Value' #+END_SRC #+RESULTS: : No Session, Result Value * Second Try with IPython Execute the following and re-run the test code above. #+BEGIN_SRC emacs-lisp (setq org-babel-python-command "ipython --pylab --pdb --nosep") #+END_SRC #+RESULTS: : ipython --pylab --pdb --nosep