3

I am not able to link Jupyter kernels to their parent Conda environments. After creating a new kernel linked to Conda environment, I'm getting a different version of Python and its dependencies inside Jupyter lab.

Here are the steps I followed:

Created a conda environment using:

conda create -n nlp python=3.6

conda activate nlp

(nlp) ➜ ~ python --version

Python 3.6.9 :: Anaconda, Inc.

(nlp) ➜ ~ which python

/anaconda3/envs/nlp/bin/python

Inside the environment I created a Jupyter kernel with:

(nlp) ➜ ~ python -m ipykernel install --user --name=nlp

Installed kernelspec nlp in /Users//Library/Jupyter/kernels/nlp

Investigating the created json file for the kernel:

(nlp) ➜  ~ cat /Users/<username>/Library/Jupyter/kernels/nlp/kernel.json
{
 "argv": [
  "/anaconda3/envs/nlp/bin/python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "nlp",
 "language": "python"
}%

It seems to be pointing to the environment version of Python

But when I start Jupyter Lab and select the nlp kernel, I get a different version of Python and some dependencies are missing

!python --version

Python 3.5.6 :: Anaconda, Inc.

!which python

/anaconda3/bin/python

amrakm
  • 43
  • 5
  • Does `nlp` have `ipykernel` installed? You can check with `conda list -n nlp ipykernel`. – merv Nov 27 '19 at 15:48
  • 1
    Yes, `ipykernel` installed, the output of your command: ``` # packages in environment at /anaconda3/envs/nlp: # # Name Version Build Channel ipykernel 5.1.3 py37h39e3cac_0 ``` – amrakm Nov 27 '19 at 16:32

1 Answers1

1

Could you please try the following steps:

conda activate nlp
conda install ipykernel
ipython kernel install --name nlp --user 

After these steps please try changing the kernel again in jupyter lab to "nlp".

Thanks.

Lakshmi - Intel
  • 483
  • 3
  • 10
  • 1
    This didn't work ``` (nlp) ➜ ~ conda install ipykernel Solving environment: done # All requested packages already installed. (nlp) ➜ ~ ipython kernel install --name nlp --user Installed kernelspec nlp in /Users//Library/Jupyter/kernels/nlp ``` – amrakm Nov 27 '19 at 09:19
  • 1
    No, it is macOS – amrakm Nov 27 '19 at 16:30
  • Could you please try creating a new conda environment and try installing ipykernel in that environment using the above steps – Lakshmi - Intel Nov 28 '19 at 05:32