gregsexton / ob-ipython

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

Failing to connect to a remote kernel. Emacs hangs. #133

Closed Arseny-N closed 6 years ago

Arseny-N commented 6 years ago

Hi everyone ! I am trying to run an ipython kernel remotely but get the following error in *ob-ipython-debug*

!! See Update !!

HTTP/1.1 404 Not Found
Server: TornadoServer/4.4.2
Content-Type: text/html; charset=UTF-8
Date: Mon, 16 Oct 2017 19:37:42 GMT
Content-Length: 69

<html><title>404: Not Found</title><body>404: Not Found</body></html>

Here is the code I use to start the remote kernel

cat start-kernel.sh

#!/bin/bash

function is_not_sourced() { test "X$(basename -- "$0")" = "X$1" ; }

SRV_HOST=box
SRV_ROOT=/home/arseni/x/jup/
CL_ROOT=/home/arseni/x/jup/

function start_kernel() {
    echo -e "\n\n\n\nNEW KERNEL `date`\n\n\n\n" >> $CL_ROOT/kernel.log
    ssh $SRV_HOST ipython kernel -f $SRV_ROOT/kernel.json >> $CL_ROOT/kernel.log 2>&1 &
    scp $SRV_HOST:$SRV_ROOT/kernel.json $CL_ROOT/kernel.json
}

function main() {
    start_kernel
    jupyter console --existing $CL_ROOT/kernel.json --ssh box
}

is_not_sourced "start-kernel.sh" && main

Here is the code block

#+BEGIN_SRC ipython :session /home/arseni/x/jup/kernel-ssh.json :exports both :results raw drawer
import torch
#+END_SRC

After ./start-kernel.sh an ipython console opens and it seems to work. I suspect it happens due to a version mismatch but but all seems to by in sync.

on remote machine

$ jupyter --version
4.3.0
$ jupyter console --version
5.2.0
$ ipython --version
6.1.0

on local machine

$ jupyter --version
4.3.0
$ jupyter console --version
5.2.0
$ ipython --version
6.1.0

I use conda 4.3.29 to manage the local and remote setup

Update:

I found out that the emacs version was quite old, after the update if I try to execute the remote session block emacs hangs with the executing Ipython code block... message in the mini-buffer

Here is my emacs version

$ /usr/local/bin/emacs --version
GNU Emacs 25.3.1
Arseny-N commented 6 years ago

Okay, found the issue -- was supplying the kernel.json file not the kernel-ssh.json one, I might have changed it before the emacs update and forgot about it.