From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hendy Subject: Re: python sessions Date: Wed, 20 Mar 2013 10:38:32 -0500 Message-ID: References: <51496061.20706@easy-emacs.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:57227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIL65-000533-3P for emacs-orgmode@gnu.org; Wed, 20 Mar 2013 11:38:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIL62-0008HR-GK for emacs-orgmode@gnu.org; Wed, 20 Mar 2013 11:38:37 -0400 Received: from mail-la0-x236.google.com ([2a00:1450:4010:c03::236]:37511) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIL62-0008HB-8y for emacs-orgmode@gnu.org; Wed, 20 Mar 2013 11:38:34 -0400 Received: by mail-la0-f54.google.com with SMTP id gw10so3222758lab.13 for ; Wed, 20 Mar 2013 08:38:33 -0700 (PDT) In-Reply-To: <51496061.20706@easy-emacs.de> 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: =?UTF-8?Q?Andreas_R=C3=B6hler?= Cc: emacs-orgmode@gnu.org On Wed, Mar 20, 2013 at 2:08 AM, Andreas R=C3=B6hler wrote: > Am 20.03.2013 01:04, schrieb John Hendy: > >> On Tue, Mar 19, 2013 at 4:40 PM, Gary Oberbrunner >> wrote: >>> >>> I must be failing to understand something. I'm running Emacs 24.3 on >>> Windows, with latest trunk org-mode. I can't get python functions to >>> persist across blocks in session mode. Here's my foo.org: >> You should probably post your babel configuration from .emacs. This >> works for me (mostly). I'm using python 3.3 > > > Hi John, > > let's point out though that matter is not at stake. > As the OP got output, system Python must be a 2... > True, which is why I clarified my version. The foo() command still worked for me; I simply had issues due to print() syntax changes between 2 -> 3. So... I've tried to eliminate this and retried today with the following process (note setting the python command to "python2"): - Start emacs with `emacs -q` - M-x load-file ~/Desktop/minimal-config #+begin_src minimal-config ;; load path (add-to-list 'load-path "~/.elisp/org.git/lisp/") ;; setup babel languages (org-babel-do-load-languages 'org-babel-load-languages '((python .t ))) (setq org-babel-python-command "python2") #+end_src - For reference $ python2 --version Python 2.7.3 On first I get a syntax error executing the first block: #+RESULTS: : first : ... ... ... File "", line 4 : print "end first" : ^ : SyntaxError: invalid syntax On a whim, I simply inserted a newline, and it worked. Here is the full file with my executed results (C-c C-c on each block): #+begin_src orgmode file * My Document The first block says: #+BEGIN_SRC python :exports results :results output :session *PyFoo* print "first" def foo(x): print "In foo(%s)"%x return x+1 print "end first" #+END_SRC #+RESULTS: : first : ... ... ... >>> end first The result is: #+BEGIN_SRC python :exports results :results output :session *PyFoo* print "hello" print foo(100) print "bye" #+END_SRC #+RESULTS: : hello : In foo(100) : 101 : bye #+end_src orgmode file *Note:* I do not get a *PyFoo* session, only a *Python* buffer. When I got to kill emacs, here is the session info asking me if I want to kill the running buffer process: Python run *Python* /dev/pts/2 python2 -i -c import sys; sys.path.remove= ('') So, seems to work for me. This is on Arch Linux: - uname -a Linux hostname 3.8.3-2-ARCH #1 SMP PREEMPT Sun Mar 17 13:04:22 CET 2013 x86_64 GNU/Linux - emacs --version GNU Emacs 24.2.1 - M-x org-version Org-mode version 8.0-pre (release_8.0-pre-146-g73fe0a @ /home/jwhendy/.elisp/org.git/lisp/) Best regards, John > Best, > > Andreas >