Jupyter (iPython) notebook says "cannot find a kernel matching Python [Root]"

18,004

Solution 1

The following assumes you've already created a python3 venv and you're using a windows system:

  1. Open the command line and activate the python3 environment with:
    activate <environment name>
  2. On the same command line of step 1, install jupyter for python3:
    pip install jupyter
  3. Create a bat file on the folder containing the python3 notebooks:

jupyter.bat:

c:\<anaconda path>\envs\<environment name>\Scripts\jupyter-notebook.exe
  1. Now just run jupyter.bat and it should open the default browser with all the python3 notebooks on the current folder.

Solution 2

I have not had time to fully digest the answer in the post you reference: Using both Python 2.x and Python 3.x in IPython Notebook -- but if what you currently have isn't working properly then what I would suggest is:

  1. Install Anaconda if you haven't already (it sounds like you probably have done this).

  2. conda update conda to update to the latest Conda (always a good idea)

  3. conda install anaconda=4.1.1 to make sure you have the latest Anaconda (well, as of this date)

  4. conda create -n ana41py27 anaconda python=2.7 to create a Python 2.7 based Conda environment that contains all the Anaconda packages

  5. conda create -n ana41py35 anaconda python=3.5 to create a Python 3.5 based Conda environment that contains all the Anaconda packages

If you have any problems with those steps, report them here or on the Anaconda mailing list.

Once you have that in place you can start Jupyter notebook (any way you like, pretty much), and then you will be able to create new notebooks that are either Python 2.7 or Python 3.5 based by choosing the appropriate kernel from the "New" button:

enter image description here

or change between a Python 2.7 or Python 3.5 kernel from within a Notebook:

enter image description here

Share:
18,004
Admin
Author by

Admin

Updated on July 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I'm interested in using Jupyter notebooks with both Python 2 and Python 3 (one of my colleagues insists on still using Python 2 ;) ).

    So I diligently followed the steps listed in this excellent answer: Using both Python 2.x and Python 3.x in IPython Notebook.

    I installed multiple kernels and now Jupyter notebooks has the option to use both Python 2 and Python 3!

    However, I managed to somehow delete the Python[Root] kernel. Now, every time I open a notebook, it comes up with an error message and makes me choose between Python 2 and Python 3 kernel.

    This is not the end of the world, but I'd like it to default to my Python[Root] kernel every time I open a new notebook. I use Anaconda by the way.

    Thanks for the assistance!