ouseful-testing / codespaces-jupyter-tm351

Explore machine learning and data science with Codespaces
MIT License
0 stars 0 forks source link

No Jupyter Kernel in VS Code #1

Open psychemedia opened 1 year ago

psychemedia commented 1 year ago

The JupyterLab environment will connect to the jupyter kernel but VS Code want.

It looks as if it may be trying to start the kernel using /usr/local/share/jupyter/kernels/python3/kernel.json:

{
 "argv": [
  "python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3 (ipykernel)",
 "language": "python",
 "metadata": {
  "debugger": true
 }

but there is no python command, only python3. The kernel.json file is owned by root and, of course, we don't have root access inside the container...

-rw-r--r-- 1 root root 193 Aug 13 2021 /usr/local/share/jupyter/kernels/python3/kernel.json

However, running the devcontainer locally, using:

docker exec -it --user root CONTAINER_NAME /bin/bash

to enter as root, then using vi (ESC-i to insert; ESC : wq to save and quit) then restarting the container and reconnecting the VS Code environment doesn't discover the kernel. So how is Jupyter finding it?

The jupyter kernelspec list command inside the container gives just:

/usr/local/share/jupyter/kernels/python3

so that is the right path?

So what is {connection_file}??? Ah, just the name to give the file, maybe...

psychemedia commented 1 year ago

Hmmm... Running python in the container works from the VS Code terminal inside the container locally, but not in the remote Codespace?

psychemedia commented 1 year ago

Fixing the kernel.json file in https://github.com/ouseful-testing/codespace-tm351-test via a docker-compose rebuild of the container to modify the kernel.json file fixed things?

FROM ouvocl/vce-tm351-jh:22j-b6

USER root
RUN sed -i 's/  "python",/  "python3",/g' /usr/local/share/jupyter/kernels/python3/kernel.json

USER $NB_USER

But try to replace the image with the compose led rebuild in this repo just errored. Simplest thing may be just to make sure the container works by modding it and pushing an update to Dockerhub.

But then again - maybe not... it seems we are finding another Python environment, not the intended one????

I note there is also a python-is-python3 Linux package for Linux 20+ that will use python as an alias for python3.

psychemedia commented 1 year ago

Don't use a kernel - just use the environment.