Python 3.x 为什么在拥有python3内核的jupyter笔记本中,sys.version显示的是2.7.2,而不是python3.x

Python 3.x 为什么在拥有python3内核的jupyter笔记本中,sys.version显示的是2.7.2,而不是python3.x,python-3.x,python-2.7,jupyter-notebook,kernel,Python 3.x,Python 2.7,Jupyter Notebook,Kernel,在jupyter笔记本中,我使用python3内核,但我键入sys.version,如图所示 2.7.2 ... ,我期望3.x import sys, platform sys.version '2.7.12 (default, Nov 12 2018, 14:36:49) \n[GCC 5.4.0 20160609]' platform.python_version() '2.7.12' 我预计输出为3.x,但在您的终端类型中,实际输出为2.7。以下是检查内核设置是否正确的方法,例如,我的

在jupyter笔记本中,我使用python3内核,但我键入sys.version,如图所示 2.7.2 ... ,我期望3.x

import sys, platform
sys.version
'2.7.12 (default, Nov 12 2018, 14:36:49) \n[GCC 5.4.0 20160609]'
platform.python_version()
'2.7.12'

我预计输出为3.x,但在您的终端类型中,实际输出为2.7

。以下是检查内核设置是否正确的方法,例如,我的如下所示

schlator@lenovo:~$ jupyter kernelspec list
Available kernels:
  ir           /home/schlator/.local/share/jupyter/kernels/ir
  julia-1.0    /home/schlator/.local/share/jupyter/kernels/julia-1.0
  python2      /home/schlator/.local/share/jupyter/kernels/python2
  python3      /home/schlator/anaconda3/share/jupyter/kernels/python3

如果您看到意外情况,您可能必须安装python3内核。

@Schlator,我修改了内核json文件,获得了python3内核的正确版本,但始终断开连接,您有什么好主意吗?谢谢