原来机器里装的是 anaconda2,默认的Python是2.7版本,默认的 jupyter notebook 也是基于Python 2内核的。

添加Python 3 的命令:

➜  ~ ipython3 kernelspec install-self
[TerminalIPythonApp] WARNING | Subcommand `ipython kernelspec` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter kernelspec` in the future
[InstallNativeKernelSpec] WARNING | `jupyter kernelspec install-self` is DEPRECATED as of 4.0. You probably want `ipython kernel install` to install the IPython kernelspec.
[InstallNativeKernelSpec] Installed kernelspec python3 in /usr/local/share/jupyter/kernels/python3

机器上安装了两个iPython。ipython3是基于Python 3 的。 报了警告,但jupyter notebook 中已经有了Python 3 的选项了,上面的命令好使。