Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change jupyter kernel from Python 2 to python 3?

I have installed Jupiter notebook and I only have python 2 as a default kernel. I want to change it from python 2 to python 3. How could I do that?Here is the screenshot.

like image 252
Satyam Singh Avatar asked Mar 22 '18 12:03

Satyam Singh


1 Answers

You can do this with the following steps:

  1. conda create -n py36 'python=3.6' ipykernel #Replace 3.6 with desired version.

  2. To activate installed jupyter kernal you need run, source activate py36

  3. python -m ipykernel install --user

  4. The interesting part: if you want to switch between kernels (py2-py3) in the same notebook, you need to run, conda install nb_conda

However, if at any point you realize that some of the modules are not available, for that you need to check Anaconda Python version.

python - version

if it is not python 3.x, you need to run

conda create -n py36 python=3.6 anaconda
source active py36

I hope it helps and enjoy switching python versions in the same notebook. You can try to print something in both python2 and python 3.

like image 99
sargupta Avatar answered Oct 06 '22 17:10

sargupta