1

I need some help to configure properly anaconda to run python3 code inside org-mode files with babel.

Somehow when I try to run code from libraries in Anaconda, babel does not recognize it. Here is the results that I get from the code run in org-mode

#+BEGIN_SRC python :session :results value
import pandas as pd

my_df = pd.DataFrame({'Col1': [2, 7, 9], 'Col2': [1, 6, 12], 'Col3': [1, 6, 9]})
my_df

#+END_SRC

#+RESULTS:
: <_ast.Expr object at 0x7f20e28f5c50>

And the iPython terminal returns:

In [7]: 'org_babel_python_eoe'

In [7]: Out[7]: 'org_babel_python_eoe'

The corresponding details of my init file are here

    ;; ELPY
(package-initialize)
(elpy-enable)

    ;; Initialise anaconda
(setq python-shell-virtualenv-path "/home/teoten/anaconda3/bin/python3")

    ;; iphython
(setq python-shell-interpreter "/home/teoten/anaconda3/bin/ipython3"
      python-shell-interpreter-args "-i --simple-prompt")

 ;; Set org-babel 
 (setq org-confirm-babel-evaluate nil)

 (org-babel-do-load-languages
    'org-babel-load-languages
    '((R . t)
      (python . t)
      (lisp . t)
      (latex . t)))

What am I doing wrong? Is it the virtualenv-path? I already tried different options with no success

  • Not sure what is happening. FWIW, I get the data frame printed out, with the standard python3/ipython3 interpreters. But I don't know what wrinkles anaconda brings (if any). – NickD Jan 27 '20 at 13:50
  • Thanks for the tip, I tried with standard python3 and in different linux distro and the problem is the same. Only difference is that now the python3 terminal in emacs returns `__org_babel_python_fname = '/tmp/babel-ARMW7g/python-XS19KD'; __org_babel_python_fh = open(__org_babel_python_fname); exec(compile(__org_babel_python_fh.read(), __org_babel_python_fname, 'exec')); __org_babel_python_fh.close()` – Manuel Teodoro Jan 28 '20 at 07:21

0 Answers0