1

I get an error when running Jupyter Notebooks in VS code due to: ipykernel not installed in my_env

enter image description here.

Running cells with 'Python 3.7.7 ('my_env')' requires ipykernel package.
Run the following command to install 'ipykernel' into the Python environment. 
Command: 'conda install -n my_env ipykernel --update-deps --force-reinstall'

But I already have installed ipykernel in both base and my_env, and have already installed a new kernel in my_env following.

(base) user@username folderA % pip show ipykernel
Name: ipykernel
Version: 6.9.1

(my_env) user@username folderA % pip show ipykernel
Name: ipykernel
Version: 6.9.1

(my_env) user@username folderA % python -m ipykernel install --user --name=my_env

Also, when running the proposed conda install -n my_env ipykernel --update-deps --force-reinstall and reloading the window, the issue re-appears.

I have tried multiple solutions, like the proposed in sol1, sol2 and also pip install --upgrade jupyter_client, but nothing works.

I am using macOS with M1 chip and conda 23.1.0 Let me know if I need to add additional details.

s223
  • 59
  • 6
  • Is the kernel you selected consistent with the environment where the library is installed? If you run jupyter in a basic environment, will it work? – MingJie-MSFT Feb 06 '23 at 01:24
  • Managed to solve it. The problem was related to my installation of python in the environment. I re-started from scratch in a new environment and worked. – s223 Feb 16 '23 at 11:21

1 Answers1

0

I found a solution. The problem was related to my installation of jupyter in the selected environment.

I re-started from scratch in a new environment, and followed the below steps in order:

conda create env -n env_name python=3.XX       
conda activate env_name               
conda install jupyter 
conda install -c anaconda ipykernel
python -m ipykernel install --user --name=env_name
s223
  • 59
  • 6