gregsexton / ob-ipython

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

ob-ipython fails when Emacs python REPL different from Jupyter python #149

Open dabro opened 6 years ago

dabro commented 6 years ago

The new experimental jupyter-X kernel feature is working GREAT!

image

However, I had to go in and customize python-shell-interpreter to python3 to work. That's because (in my case) the Spacemacs python layer configures the REPL to ipython. In that case, python-shell-interpreter returns ipython,

(defun ob-ipython--get-python ()
  (locate-file (if (eq system-type 'windows-nt)
                   "python.exe"
                 (or python-shell-interpreter "python"))
               exec-path))

which fails to accept accept the passed arguments and fails to find jupyter_client to import.

Also, (in my case), python is 2.7. However, Jupyter is installed as Python 3, so jupyter_client failed to import in client.py.

While pyenv is supposed to deal with these issues, I would imagine it's always going to be possible/likely that someone's emacs config might have a different version of python than their Jupyter install. Maybe always running client.py from an ipython console process vs python process, on the assumption that jupyter should always be able to find jupyter components and already be in the right python environment?

mashu commented 6 years ago

I am not sure if this is related, but when I use ob-python, it correctly starts python3, but when I use ob-ipython, it fails back to python 2.7 which is wrong. I have pyenv with jupyter installed for python3.

Also I get this error when executing code block

executing Ipython code block...
apply: Searching for program: No such file or directory, jupyter

This is because wrong version of python is used. Everywhere in config I have python3 configured, no idea why it picks 2.7.

Thanks