0

I have created a conda environment called Foo. After activating this environment I installed Kedro with pip, since conda was giving me a conflict. Even though I'm inside the Foo environment, when I run:

kedro jupyter lab

It picks up the modules from my base environment, not the Foo environment. Any idea, why this is happening, and how I can change what modules my notebook detect?

Edit

By mangling with my code I found out that on the \AppData\Roaming\jupyter\kernels\kedro_project\kernel.json it was calling the python from the base environment, not the Foo environment. I changed it manually, but is there a mode automatic way of setting the \AppData\Roaming\jupyter\kernels\kedro_project\kernel.json to use the current environment I'm on?

João Areias
  • 1,192
  • 11
  • 41
  • Have you installed packages with `pip install --user`? Conda does not block the user site by default. – merv May 17 '22 at 15:10

3 Answers3

1

The custom Kedro kernel spec is a feature that I recently added to Kedro. When you run kedro jupyter lab/notebook it should automatically pick up on the conda environment without you needing to manually edit the kernel.json file. I tested this myself to check that it worked so I'm very interested in understanding what's going on here!

The function _create_kernel is what makes the the Kedro kernel spec. The docstring for that explains what's going on, but in short we delegate to ipykernel.kernelspec.install. This generates a kernelspec that points towards the Python path given by sys.executable (see make_ipkernel_cmd). In theory this should already point towards the correct Python path, which takes account of the conda environment.

It's worth checking which kedro to see which conda environment that points to, and if we need to debug further then please do raise an issue on our Github repo. I'd definitely like to get to the bottom of this and understand where the problem is.

P.S. you can also do a plain jupyter lab/notebook to launch a kernel with the right conda environment and then run %load_ext kedro.extras.extensions.ipython in the first cell. This is basically equivalent to using the Kedro kernelspec, which loads the Kedro IPython extension automatically.

Antony Milne
  • 141
  • 3
0

This is likely a problem with jupyter. I'd suggest trying to run jupyter notebook and understand if it is down to kedro or jupyter.

I remember facing something similar due to some jupyter problem but don't remember how I fixed it. I remember trying some solutions from this issue on jupyter.

avan-sh
  • 11
  • 2
0

Try do pip install jupyterlab in your foo enviornment, Jupyter Kernel is a different concept and acts weird sometimes.

mediumnok
  • 180
  • 1
  • 9