Closed CdtDelta closed 1 year ago
Oh that's so cool you are running it in Raspberry pi!
From the logs, it seems gonb failed to execute:
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]: FileNotFoundError: [Errno 2] No such file or directory: 'gonb'
Would you mind running the following under the user you are going to run JupyterLab on:
$ gonb --install --logtostderr
And then looking at the same users's file ~/.local/share/jupyter/kernels/gonb
?
There it should have saved the path to the gonb
, and it will pick up the same as the one it used to execute gonb
from.
One potential issue was that gonb --install
was run from a different user than the one running jupyterlab ? I'm not sure, but let me know how it goes -- if something needs fixing I can do it really quick.
Here is installation code, it's very simple:
https://github.com/janpfeifer/gonb/blob/main/kernel/install.go#L27
Another hypothesis is that when gonb --install
was executed, gonb
was in the path, and when JupyterLab runs, it is not. I probably should save the absolute path to gonb, in line 29 of the file above. So if the test above doesn't work, would you mind manually editing the absolute path to gonb
in your ~/.local/share/jupyter/kernels/gonb
? If that fixes it, I'll create a fix to do this automatically.
So the user that I ran the install from is the same user jupyterlab is running under. That was one of the items I checked before posting my original issue. I had problems getting go to run in the past on jupyter with this same set up (the other go project that are out there similar to yours). But I rebuilt my Pi this time around to eliminate anything I may have screwed up in the first go around.
Here's the output from the kernel.json file after running $ gonb -install -logtostderr
:
{"argv":["gonb","--kernel","{connection_file}","--logtostderr"],"display_name":"Go (gonb)","language":"go","env":{}}
I did a which gonb on the CLI and got:
which gonb
/home/USER/go/bin/gonb
I edited the kernel.json file so it now reads:
{"argv":["/home/pi/go/bin/gonb","--kernel","{connection_file}","--logtostderr"],"display_name":"Go (gonb)","language":"go","env":{}}
But now when I open a gonb notebook I get:
Jul 11 15:59:01 HOSTNAME jupyter-lab[49388]: [I 2023-07-11 15:59:01.576 ServerApp] Creating new notebook in
Jul 11 15:59:02 HOSTNAME jupyter-lab[49404]: I0711 15:59:02.349634 49404 main.go:78] #033[7;39;32m[24d5a0af]#033[0m kernel created
Jul 11 15:59:02 HOSTNAME jupyter-lab[49404]: E0711 15:59:02.352100 49404 goexec.go:74] #033[7;39;32m[24d5a0af]#033[0m Failed to run `go mod init gonb_24d5a0af`:
Jul 11 15:59:02 HOSTNAME jupyter-lab[49404]: #033[7;39;32m[24d5a0af]#033[0m 2023/07/11 15:59:02 Failed to create go executor: exec: "go": executable file not found in $PATH
Jul 11 15:59:02 HOSTNAME jupyter-lab[49404]: failed to run "go mod init gonb_24d5a0af"
Jul 11 15:59:02 HOSTNAME jupyter-lab[49404]: github.com/janpfeifer/gonb/goexec.New
Jul 11 15:59:02 HOSTNAME jupyter-lab[49404]: #011/home/USER/go/pkg/mod/github.com/janpfeifer/gonb@v0.7.2/goexec/goexec.go:75
Jul 11 15:59:02 HOSTNAME jupyter-lab[49404]: main.main
Jul 11 15:59:02 HOSTNAME jupyter-lab[49404]: #011/home/USER/go/pkg/mod/github.com/janpfeifer/gonb@v0.7.2/main.go:85
Jul 11 15:59:02 HOSTNAME jupyter-lab[49404]: runtime.main
Jul 11 15:59:02 HOSTNAME jupyter-lab[49404]: #011/usr/local/go/src/runtime/proc.go:250
Jul 11 15:59:02 HOSTNAME jupyter-lab[49404]: runtime.goexit
Jul 11 15:59:02 HOSTNAME jupyter-lab[49404]: #011/usr/local/go/src/runtime/asm_arm64.s:1172
Jul 11 15:59:02 HOSTNAME jupyter-lab[49388]: [I 2023-07-11 15:59:02.375 ServerApp] Kernel started: 376913be-1cc7-4d9e-bf0b-d8b01f778285
I also confirmed that Jupyterlab is running under my USER account:
USER 49388 1 4 15:58 ? 00:00:09 /usr/bin/python3 /home/USER/.local/bin/jupyter-lab --config=/home/USER/.jupyter/jupyter_lab_config.py
Ok, I added a fix to install the absolute path to gonb
, so this first issue won't happen next time (after the next release).
Now the issue seems to be with your "PATH" variable. First it was not finding gonb
. Now it doesn't seem to find the go
command. It assume go
is in the path, and it seems to be complaining it doesn't find it:
Failed to create go executor: exec: "go": executable file not found in $PATH
Would you mind adding your path to go
and ${GOBIN}
(you can read this with go env GOBIN
) to your PATH
, before executing JupyterLab ?
Now, I could add a test for go
being in the PATH
during the installation process, but I'm suspecting this wouldn't help you, because you execute jupyter-lab
with a different PATH
? Or is it not the case ?
That's the weird part, go AND gonb are both in my path:
$echo $PATH
/home/USER/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin:/home/USER/go/bin
$ which go
/usr/local/go/bin/go
$ which gonb
/home/USER/go/bin/gonb
As far as I know, I'm not executing jupyter-lab with a different path, but TBH I don't know the inner workings of jupyter-lab well enough to determine that.
However, it looks like I don't have GOBIN defined, if I do an echo $GOBIN
it returns empty.
Looking at the go docs, it doesn't appear that it's needed.
The default location of $GOPATH is $HOME/go, and it's not usually necessary to set GOPATH explicitly. However, if you have checked out the Go distribution to $HOME/go, you must set GOPATH to another location to avoid conflicts. By default, $GOBIN is $GOPATH/bin (or $HOME/go/bin if GOPATH is not set). After installing, you will want to add this directory to your $PATH so you can use installed tools.
Yes, I think not having a $GOBIN
defined is fine, it will take the default, as you pointed out.
And I never touched on jupyter-lab
, it just always found out everything in the PATH
. I'm thinking it has something to do with your installation/configuration.
Would you be comfortable cloning a branch of gonb and running that instead ? I could do a version that check for the go binary first thing, and if it doesn't find it, it prints out the PATH, so we would know for sure ?
So version that will check for go
at the start, and print out the PATH is in https://github.com/janpfeifer/gonb/tree/gopath
.
And I think you can do this with:
git clone https://github.com/janpfeifer/gonb.git
git switch gopath
go run . --install --logtostderr
And then try JupyterLab again. It should print out the PATH ...
Here is what it changes btw:
https://github.com/janpfeifer/gonb/commit/e5468b9e6f99f10a0b3057fc0aca2d9f5dd9818d
Yeah looks like the PATH is different when it's running the service:
Jul 11 16:45:48 HOSTNAME jupyter-lab[50675]: F0711 16:45:48.037220 50675 main.go:79] #033[7;39;32m[4bc75d92]#033[0m Failed to find path for the `go` program: exec: "go": executable file not found in $PATH
Jul 11 16:45:48 HOSTNAME jupyter-lab[50675]: Current PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
I figured it out....I needed to add the following to the startup script for the jupyter service:
Environment="PATH=$PATH:/usr/local/go/bin:/home/USER/go/bin"
Once I made that change it looks like it's working now. I was able to run the Hello World sample from the tutorial.
Cool! Enjoy, and let me know if you find any other issues!
Hi, I have jupyter lab running on a Pi 4 machine. The python part of Jupyter is working, but I'm having issues getting gonb to work. I'm able to run go on the CLI and I can type gonb on the CLI and get the help menu back. But when I try to open a Gonb notebook I get the following error:
I just upgraded to 0.7.2 this morning, and the jupyter server is running under the USER account.
If there's any other info you need please let me know.