From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: Troublesome python block Date: Wed, 11 Oct 2017 16:35:15 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a114e4dd0da381a055b480266" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e2Jyj-0006KN-Q3 for emacs-orgmode@gnu.org; Wed, 11 Oct 2017 12:35:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e2Jyi-0000ne-7o for emacs-orgmode@gnu.org; Wed, 11 Oct 2017 12:35:29 -0400 Received: from mail-qt0-x232.google.com ([2607:f8b0:400d:c0d::232]:51524) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e2Jyi-0000nV-1U for emacs-orgmode@gnu.org; Wed, 11 Oct 2017 12:35:28 -0400 Received: by mail-qt0-x232.google.com with SMTP id q4so6968022qtq.8 for ; Wed, 11 Oct 2017 09:35:27 -0700 (PDT) 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" To: Roger Mason , Org-Mode --001a114e4dd0da381a055b480266 Content-Type: text/plain; charset="UTF-8" On Wed, Oct 11, 2017 at 11:26 AM Roger Mason wrote: > hello, > > This python block: > > #+BEGIN_SRC python :session true :results output > import numpy as np > from ase import Atoms > from ase.calculators.gulp import GULP, Conditions > > quartz = Atoms(symbols='Si3O6', pbc=np.array([True,True,True], > dtype=bool), > cell=np.array([[4.916, 0.0, 0.0], [-2.4579999999999993, > 4.257380885004301, 0.0], [0.0, 0.0, 5.4054]]), > positions=np.array([[ 2.3016712, 0., 1.80161982], > [-1.1508356, 1.99330573, 3.60341982], > [ 1.3071644, 2.26407515, 5.40521982], > [ 1.3767258, 1.13288905, 1.15189074], > [ 3.2465264, 0.62583499, 2.95369074], > [ 2.7507478, 2.49865684, 4.75549074], > [ 0.2927478, 1.75872404, 4.25350926], > [-1.0812742, 3.12449183, 2.45170926], > [ 0.7885264, 3.63154589, 0.64990926]])) > #+END_SRC > > produces this output: > > #+RESULTS: > #+begin_example > Python 2.7.13 (default, Jul 2 2017, 01:20:25) > [GCC 4.2.1 Compatible FreeBSD Clang 3.4.1 (tags/RELEASE_34/dot1-final > 208032)] on freebsd10 > Type "help", "copyright", "credits" or "license" for more information. > python.el: native completion setup loaded > and > as > assert > break > class > continue > def > del > elif > else > ....[SNIPPED].... > AttributeError > OverflowError > > 0__dummy_completion__ 1__dummy_completion__ > #+end_example > > The same python script produces no errors in a python interpreter > started from the command line and it reports no errors when run as > 'python twaddle.py'. > > Any help in debugging this will be much appreciated. > > Roger > > Org mode version 9.0.3 (release_9.0.3-170-gfed1cf @ > /home/rmason/.emacs.d/org-git/org-mode/lisp/) > GNU Emacs 25.2.1 (i386-portbld-freebsd10.3, GTK+ Version 3.22.15) of > 2017-07-03 > Python 2.7.13 (default, Jul 2 2017, 01:20:25) > [GCC 4.2.1 Compatible FreeBSD Clang 3.4.1 (tags/RELEASE_34/dot1-final > 208032)] on freebsd10 > I cannot recreate that, though I am on different versions for everything: - Emacs: 26.0.60 built from emacs-26 branch <-- This might be what actually matters as I know that there were quite a few python.el commits in this branch ( http://git.savannah.gnu.org/cgit/emacs.git/log/?h=emacs-26&qt=grep&q=python ). - Org: built from Org master branch - Python 3.6.2 I haven't used numpy or ase/scipy, so after: > pip3 install --user numpy > pip3 install --user scipy I get: #+PROPERTY: header-args:python :exports both :results output #+BEGIN_SRC python import numpy as np from ase import Atoms from ase.calculators.gulp import GULP, Conditions quartz = Atoms(symbols='Si3O6', pbc=np.array([True,True,True], dtype=bool), cell=np.array([[4.916, 0.0, 0.0], [-2.4579999999999993, 4.257380885004301, 0.0], [0.0, 0.0, 5.4054]]), positions=np.array([[ 2.3016712, 0., 1.80161982], [-1.1508356, 1.99330573, 3.60341982], [ 1.3071644, 2.26407515, 5.40521982], [ 1.3767258, 1.13288905, 1.15189074], [ 3.2465264, 0.62583499, 2.95369074], [ 2.7507478, 2.49865684, 4.75549074], [ 0.2927478, 1.75872404, 4.25350926], [-1.0812742, 3.12449183, 2.45170926], [ 0.7885264, 3.63154589, 0.64990926]])) print(quartz) #+END_SRC #+RESULTS: : Atoms(symbols='Si3O6', pbc=True, cell=[[4.916, 0.0, 0.0], [-2.4579999999999993, 4.257380885004301, 0.0], [0.0, 0.0, 5.4054]]) Is that what you expected in the RESULTS? Here is my relatively simply python setup where I default the interpreter to python3: https://github.com/kaushalmodi/.emacs.d/blob/master/setup-files/setup-python.el and my minimal ob-python setup: (use-package ob-python :defer t :config (progn (setq org-babel-python-command "python3"))) ;Default to python 3.x -- Kaushal Modi --001a114e4dd0da381a055b480266 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Oct 11= , 2017 at 11:26 AM Roger Mason <rmason@= mun.ca> wrote:
hello,

This python block:

#+BEGIN_SRC python :session true :results output
=C2=A0 import numpy as np
=C2=A0 from ase import Atoms
=C2=A0 from ase.calculators.gulp import GULP, Conditions

=C2=A0 quartz =3D Atoms(symbols=3D'Si3O6', pbc=3Dnp.array([True,Tru= e,True], dtype=3Dbool),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cell=3Dnp.array([[4.916, 0.0, 0.0]= , [-2.4579999999999993, 4.257380885004301, 0.0], [0.0, 0.0, 5.4054]]),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0positions=3Dnp.array([[ 2.3016712,= =C2=A0 =C2=A00.,=C2=A0 =C2=A0 =C2=A0 1.80161982],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 [-1.1508356, 1.99330573, 3.60341982],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 [ 1.3071644, 2.26407515, 5.40521982],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 [ 1.3767258, 1.13288905, 1.15189074],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 [ 3.2465264, 0.62583499, 2.95369074],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 [ 2.7507478, 2.49865684, 4.75549074],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 [ 0.2927478, 1.75872404, 4.25350926],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 [-1.0812742, 3.12449183, 2.45170926],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 [ 0.7885264, 3.63154589, 0.64990926]]))
#+END_SRC

produces this output:

#+RESULTS:
#+begin_example
Python 2.7.13 (default, Jul=C2=A0 2 2017, 01:20:25)
[GCC 4.2.1 Compatible FreeBSD Clang 3.4.1 (tags/RELEASE_34/dot1-final 20803= 2)] on freebsd10
Type "help", "copyright", "credits" or "= license" for more information.
python.el: native completion setup loaded
and
as
assert
break
class
continue
def
del
elif
else
....[SNIPPED]....
AttributeError
OverflowError

0__dummy_completion__=C2=A0 1__dummy_completion__
#+end_example

The same python script produces no errors in a python interpreter
started from the command line and it reports no errors when run as
'python twaddle.py'.

Any help in debugging this will be much appreciated.

Roger

Org mode version 9.0.3 (release_9.0.3-170-gfed1cf @
/home/rmason/.emacs.d/org-git/org-mode/lisp/)
GNU Emacs 25.2.1 (i386-portbld-freebsd10.3, GTK+ Version 3.22.15) of 2017-0= 7-03
Python 2.7.13 (default, Jul=C2=A0 2 2017, 01:20:25)
[GCC 4.2.1 Compatible FreeBSD Clang 3.4.1 (tags/RELEASE_34/dot1-final 20803= 2)] on freebsd10

I cannot recreate that= , though I am on different versions for everything:

- Emacs: 26.0.60 built from emacs-26 branch <-- This might be what act= ually matters as I know that there were quite a few python.el commits in th= is branch (=C2=A0http://git.savannah.gnu.org/cgi= t/emacs.git/log/?h=3Demacs-26&qt=3Dgrep&q=3Dpython=C2=A0).
- Org: built from Org master branch
- Python 3.6.2

I haven't used numpy or ase/scipy, so after:

> pip3 install --user numpy=C2=A0
> pip3 in= stall --user scipy

I get:

#+PROPERTY: header-args:python :exports both :results output
#+BEGIN_SRC python
import numpy as np
= from ase import Atoms
from ase.calculators.gulp import GULP, Cond= itions

quartz =3D Atoms(symbols=3D'Si3O6',= pbc=3Dnp.array([True,True,True], dtype=3Dbool),
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0cell=3Dnp.array([[4.916, 0.0, 0.0], [-2.457999999999999= 3, 4.257380885004301, 0.0], [0.0, 0.0, 5.4054]]),
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0positions=3Dnp.array([[ 2.3016712,=C2=A0 =C2=A00.,=C2= =A0 =C2=A0 =C2=A0 1.80161982],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [-1.1508356, 1.99330573, 3.60341982],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 [ 1.3071644, 2.26407515, 5.40521982],
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [ 1.3767258, 1.13288905, 1= .15189074],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 [ 3.2465264, 0.62583499, 2.95369074],
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [ 2.7507478,= 2.49865684, 4.75549074],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [ 0.2927478, 1.75872404, 4.25350926],
=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = [-1.0812742, 3.12449183, 2.45170926],
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [ 0.7885264, 3.63154589, 0.64990= 926]]))
print(quartz)
#+END_SRC

#+RESULTS:
: Atoms(symbols=3D'Si3O6', pbc=3DTrue, cell= =3D[[4.916, 0.0, 0.0], [-2.4579999999999993, 4.257380885004301, 0.0], [0.0,= 0.0, 5.4054]])


Is that what = you expected in the RESULTS?

Here is my relatively= simply python setup where I default the interpreter to python3:=C2=A0https://github.com/kaushalmodi/.emacs.d/blob/master/setup-files= /setup-python.el

and my minimal ob-python setu= p:

(use-package ob-python
=C2=A0 :d= efer t
=C2=A0 :config
=C2=A0 (progn
=C2=A0 = =C2=A0 (setq org-babel-python-command "python3"))) ;Default to py= thon 3.x

--

Kaushal Modi

--001a114e4dd0da381a055b480266--