emacs-jupyter / jupyter

An interface to communicate with Jupyter kernels.
GNU General Public License v3.0
914 stars 89 forks source link

jupyter-run-repl is picking up wrong python #529

Open justrajdeep opened 4 months ago

justrajdeep commented 4 months ago

Hi

I am trying to set up jupyter 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))

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 $@

but when i am trying to run M-x jupyter-run-repl it is picking up some other python is getting picked up, i get

Launching python3 kernel...
jupyter--start-kernel-process: Kernel process exited:
/home/utils/meld-3.16.3/bin/python: No module named ipykernel_launcher

Process jupyter-kernel-python3 exited abnormally with code 1

This python is not what i want.

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
        }
      }
    }
  }
}

Please advice. TIA.

justrajdeep commented 4 months ago

https://github.com/emacs-jupyter/jupyter/issues/306#issuecomment-1166182983

Helped me

#+begin_src emacs-lisp
 (advice-remove #'org-babel-do-load-languages #'ignore)
#+end_src

 #+begin_src emacs-lisp
(org-babel-do-load-languages
 'org-babel-load-languages
 '(
   (emacs-lisp . t)
   ;; (julia . t)
   (shell . t)
   (python . t)
   (jupyter . t)
))

#+end_src

which gives

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

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

Original Value
((emacs-lisp . t))

when i try to run M-x jupyter-run-repl i get

Launching python3 kernel...
Starting python3 kernel process...done
Launching python3 kernel...done
Requesting kernel info...
Loading /home/scratch.rmondal_mobile/home/doom_emacs/.local/straight/build-29.1/zmq/emacs-zmq (module)...
apply: Module could not be opened: "/home/scratch.rmondal_mobile/home/doom_emacs/.local/straight/build-29.1/zmq/emacs-zmq.so", "/lib64/libc.so.6: version `GLIBC_2.33' not found (required by /home/scratch.rmondal_mobile/home/doom_emacs/.local/straight/build-29.1/zmq/emacs-zmq.so)"