FileNotFoundError: [Errno 2] No such file or directory#

Updated on 01 August 2022

See Wrapper packages here.

Issue#

you:

  • created your own conda env

  • installed ipykernel and package x package y

  • created a kernel for jupyterhub as described here

but ìmport package x or other related packages does not work:

FileNotFoundError: [Errno 2] No such file or directory:

Example#

  • python-cdo

FileNotFoundError: [Errno 2] No such file or directory: 'cdo'

Why?#

python-cdo is just a binding, it requires cdo binary from the software tree. When you start your own kernel in jupyterhub cdo is not loaded per default.

Solution#

The easiest way to add path to missing library is to modify the kernel.json as described here. For the cdo example, the kernel.json looks like this:

{
"argv": [
  "DO NOT CHANGE THIS!",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
],
"display_name": "name of your kernel",
"language": "python",
"env": {
"PATH":
       "$PATH:/sw/rhel6-x64/cdo/cdo-1.9.8-magicsxx-gcc64/bin"
       }
}

You need to restart the kernel after you change this.

Note

kernel.json can be found in .local/share/jupyter/kernels/your_kernel/.