jupyter icon indicating copy to clipboard operation
jupyter copied to clipboard

jupyter-run-repl is picking up wrong python

Open justrajdeep opened this issue 11 months ago • 1 comments

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 avatar Mar 03 '24 16:03 justrajdeep