15

I am using ipython 6.4.0 on ubuntu 20.04 and using jupyter kernelspec list , I found, there are 2 kernels :

  1. practice_applied_ai
  2. python3

When I open any .ipynb file, it directly opens in "python3" but I want to open it in "practice_applied_ai" because I created virtual environment practice_applied_ai and only in this kernel I can import Tensorflow 2.2.0 for my work.
My question is, Is there any way to change my default kernel without removing any kernel ?

1
  • 2
    I have the same issue. What I found and tried was the following: setting the following in the jupyter_notebook_config.py, but this seems to be ignored when opening new notebooks: cMultiKernelManager.default_kernel_name = 'own_kernel' Commented Jul 31, 2020 at 11:49

3 Answers 3

19
jupyter notebook --generate-config 

open the generated config file change
change this line to your desired kernel

#c.MultiKernelManager.default_kernel_name = 'python3' 

like

c.MultiKernelManager.default_kernel_name = 'py38' 
Sign up to request clarification or add additional context in comments.

3 Comments

In the config file, MultiKernelManager comes before MappingKernelManager, so, this is a better answer!
Sadly this did not work for me. It keeps reverting back to the original.
How do you do this for a specific project directory? The above sets the user configuration for Jupyter lab at ~/ .jupyter instead
13

See this answer on GitHub. As explained there:

the default kernel name is rarely used. It really only comes into play when a request is received to start a kernel and the kernel name is not specified in the request payload. Since both Notebook and Lab UIs essentially require the user to select a kernel (for new notebooks), it doesn't really come into play.

Put c.MappingKernelManager.default_kernel_name='newDefault' in config file.

To confirm the default is in place, hit the kernelspecs REST API of your running notebook server (e.g., http://localhost:8888/api/kernelspecs) and you should see the default kernel name as the first entry in the returned payload.

1 Comment

Thanks for the tip on visiting localhost:8888/api/kernelspecs. Great sanity check
3

Yes this is possible via the .ipynb file itself. Set the following variables in the metadata, specifically the name which identifies the kernel

  "metadata": {
   "kernelspec": {
   "display_name": "Python 3 (PyTorch 1.6 Python 3.6 CPU Optimized)",
   "language": "python",
   "name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-east-1:081325390199:image/pytorch-1.6-cpu-py36-ubuntu16.04-v1"
   },
   "language_info": {
    "codemirror_mode": {

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.