Reputation: 61
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!
Upvotes: 6
Views: 22239
Reputation: 99011
The following assumes you've already created a python3
venv and you're using a windows system:
activate
the python3
environment with:activate <environment name>
jupyter
for python3
:pip install jupyter
bat
file on the folder containing the python3
notebooks: jupyter.bat:
c:\<anaconda path>\envs\<environment name>\Scripts\jupyter-notebook.exe
python3
notebooks on the current folder.Upvotes: 2
Reputation: 10576
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:
Install Anaconda if you haven't already (it sounds like you probably have done this).
conda update conda
to update to the latest Conda (always a good idea)
conda install anaconda=4.1.1
to make sure you have the latest Anaconda (well, as of this date)
conda create -n ana41py27 anaconda python=2.7
to create a Python 2.7 based Conda environment that contains all the Anaconda packages
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:
or change between a Python 2.7 or Python 3.5 kernel from within a Notebook:
Upvotes: 1