Score:0

Open a Jupyter Notebook with Python 3

cn flag

I have both python 2 and python 3 installed on Ubuntu 18.04 LTS:

If I do python -V and python3 -V in my terminal, I get Python 2.7.17 and Python 3.6.9 respectively.

When I open a Jupyter Notebook I only have an option to open a Python 2 notebook. How can I open a python 3 notebook?

When I search for answers, I see solutions that involve installing anaconda - but I already have both Jupyter Notebook and Python 3 on my machine. I don't want to mess things up by installing further versions of python and Jupyter Notebook if I don't need to. Is this best way to do this via anaconda?

Score:1
us flag

python as such is not a command. It is link to a version of python either 2.x or 3.x. In your case, it is pointing to python 2.x

so when you installed ipykernel using python -m ipykernel install --user or python -m pip install ipykernel it installed as python2.x.

to fix this, you can install ipykernel as pythion3. Just replace python with python3. so your command will be

python3 -m pip install ipykernel

Now run jupyter and check if you can see the python3.x kernel.

On a separate note, if you really don't want to mess your system with multiple version of pythons, docker images would be your best bet. It takes away all complexity of installing python and other tools.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.