无法将python3内核添加到Jupyter

时间:2017-10-16 13:14:35

标签: linux jupyter-notebook ipython-notebook jupyter

我想在Jupyter中更改内核的路径,将其设置为我在机器中使用的路径。

以下是在jupyter中安装的原始内核:

jupyter kernelspec list
  

可用内核:
  python3 /home/n/.local/share/jupyter/kernels/python3
  python2 / usr / local / share / jupyter / kernels / python2

然后我在我的机器中检查了python3的路径,如下所示:

which python3
  

的/ usr /斌/ python3

$ ipython kernelspec list

我删除了python3的内核:

jupyter kernelspec uninstall python3

成功执行,然后我尝试使用我之前找到的路径安装python3,如下所示:

  

jupyter kernelspec install / usr / bin / python3

给了我这个错误:

  

File" / usr / local / bin / jupyter-kernelspec",第11行,in       sys.exit(KernelSpecApp.launch_instance())
  文件" /usr/local/lib/python2.7/dist-packages/traitlets/config/application.py",   第658行,在launch_instance中       app.start()
  文件" /usr/local/lib/python2.7/dist-packages/jupyter_client/kernelspecapp.py",   第273行,开始       return self.subapp.start()
  文件" /usr/local/lib/python2.7/dist-packages/jupyter_client/kernelspecapp.py",   第143行,开头       取代= self.replace,
  文件" /usr/local/lib/python2.7/dist-packages/jupyter_client/kernelspec.py",   第299行,在install_kernel_spec中       shutil.copytree(source_dir,destination)
  文件" /usr/lib/python2.7/shutil.py" ;,第171行,在copytree中

     

names = os.listdir(src)OSError:[Errno 20]不是目录:' / usr / bin / python3'

然后我找到了正确的道路:

python3 -c "import sys; print ('\n'.join(sys.path))"
  

/usr/lib/python3.4

     

/usr/lib/python3.4/plat-x86_64-linux-gnu

     

/usr/lib/python3.4/lib-dynload

     

/usr/local/lib/python3.4/dist-packages

     

/usr/local/lib/python3.4/dist-packages/setuptools-28.8.0-py3.4.egg

     

/ usr / lib中/ python3 / DIST-封装

我试图像这样安装它:

sudo jupyter kernelspec install /usr/lib/python3.4
  

[InstallKernelSpec]安装了kernelspec python3.4 in   /usr/local/share/jupyter/kernels/python3.4

现在,当我启动jupyter时,根本没有Python 3作为内核,我现在不知道该怎么办?

2 个答案:

答案 0 :(得分:2)

您可能还没有在python 3安装上安装ipykernel。要安装python内核,正确的步骤是:

pip3 install ipykernel

python3 -m ipykernel install --user

请参阅here

答案 1 :(得分:0)

我能够通过使用附带Jupyter附带的anaconda重新安装python3来解决这个问题。

您可以通过以下命令安装anaconda: https://conda.io/docs/user-guide/install/linux.html