为什么在具有python3内核的jupyter-notebook中,sys.version显示2.7.2,而不是python3.x

时间:2019-08-30 02:38:00

标签: 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

1 个答案:

答案 0 :(得分:0)

在终端中键入以下内容以检查您是否确实以正确的方式设置了内核,例如我的节目如下

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内核。