Cannot get python3 in Jupyter notebook

2019-04-29 05:51发布

问题:

How can I get python3 to run in Jupyter? I cannot get it to supply that kernel as well. When I run ipython3 notebook at the terminal, I check the version of Python:

import sys
print(sys.version)

where I get the output:

3.4.0 (default, Jun 19 2015, 14:20:21) 
[GCC 4.8.2]

When I run jupyter notebook, I have only the option of a new python 2 notebook and

import sys
print(sys.version)

where I get the output:

2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2]

I try to run:

sudo ipython3 kernelspec install-self
[TerminalIPythonApp] WARNING | File not found: 'kernelspec'

回答1:

I had this same problem, but solved it by making a virtualenv using Python3 as the Python binary; installed iPython; and launched iPython notebook from virtualenv. I will test to see if the same procedure works with Jupyter (I expect that it will). Note that when I did this, I only had the option of making Python 3 notebooks.

The following steps worked for me:

mkvirtualenv --python=/full/path/to/python3.5 p35
pip install jupyter
jupyter notebook

A web page popped up and I was allowed to make a Python 3 notebook.