gregsexton / ob-ipython

org-babel integration with Jupyter for evaluation of (Python by default) code blocks
737 stars 111 forks source link

missing emacs-default/emacs-none issue when running code #225

Open justrajdeep opened 5 months ago

justrajdeep commented 5 months ago

Hi

I am trying to set up ob-ipython for my emacs

Since i am in an farm box i am using poetry to create python virtual environment. I am using doom emacs as my emacs configuration.

org-babel-python-command is a variable defined in config.el.

Value
"python3"
org-babel-load-languages is a customizable variable defined in org.el.

Value
((emacs-lisp . t)
 (shell . t)
 (python . t)
 (ipython . t)
 (jupyter . t))

Original Value
((emacs-lisp . t))

so i have created ~/bin/jupyter ~/bin/python and ~/bin/python3

which have something like this

#!/bin/bash

set -e

source ~/bin/scripts/emacs_python/.venv/bin/activate

~/bin/scripts/emacs_python/.venv/bin/jupyter $@

I have verified the following in my emacs

#+begin_src emacs-lisp
(shell-command "jupyter --paths")
#+end_src

Result:

config:
    /home/scratch.rmondal_mobile/home/bin/scripts/emacs_python/.venv/etc/jupyter
    /home/rmondal/.jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /home/scratch.rmondal_mobile/home/bin/scripts/emacs_python/.venv/share/jupyter
    /home/rmondal/.local/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /home/rmondal/.local/share/jupyter/runtime

And

#+begin_src emacs-lisp
 (jupyter-locate-python)
#+end_src

#+RESULTS:
: /home/scratch.rmondal_mobile/home/bin/scripts/emacs_python/.venv/bin/python3
#+begin_src emacs-lisp
(shell-command "jupyter kernelspec list")
#+end_src

Result:

Available kernels:
  python3    /home/scratch.rmondal_mobile/home/bin/scripts/emacs_python/.venv/share/jupyter/kernels/python3
#+begin_src emacs-lisp
   (shell-command "jupyter kernelspec list --json")
#+end_src

Result

{
  "kernelspecs": {
    "python3": {
      "resource_dir": "/home/scratch.rmondal_mobile/home/bin/scripts/emacs_python/.venv/share/jupyter/kernels/python3",
      "spec": {
        "argv": [
          "python",
          "-m",
          "ipykernel_launcher",
          "-f",
          "{connection_file}"
        ],
        "env": {},
        "display_name": "Python 3 (ipykernel)",
        "language": "python",
        "interrupt_mode": "signal",
        "metadata": {
          "debugger": true
        }
      }
    }
  }
}

I created

#+BEGIN_SRC ipython :session :exports both :var x=2 :var data=data_table
  (x, data)
#+END_SRC

Error i got

Traceback (most recent call last):
  File "/home/scratch.rmondal_mobile/home/doom_emacs/.local/straight/build-29.1/ob-ipython/client.py", line 60, in <module>
    c = create_client(args.conn_file)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scratch.rmondal_mobile/home/doom_emacs/.local/straight/build-29.1/ob-ipython/client.py", line 43, in create_client
    cf = find_connection_file('emacs-' + name)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rmondal/bin/scripts/emacs_python/.venv/lib/python3.11/site-packages/jupyter_client/connect.py", line 233, in find_connection_file
    raise OSError(msg)
OSError: Could not find 'emacs-default' in ['.', '/home/rmondal/.local/share/jupyter/runtime']

Please advice. TIA.