更改Jupyter kernelspec以指向anaconda python [英] Changing Jupyter kernelspec to point to anaconda python

查看:392
本文介绍了更改Jupyter kernelspec以指向anaconda python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Anaconda来管理Python和Jupyter.那就是:

I'm using Anaconda to manage both Python and Jupyter. That is:

>> which python
>> /home/.../software/anaconda3/bin/python

>> which jupyter
>> /home/.../software/anaconda3/bin/jupyter

但是Jupyter的python内核似乎指向的是系统版本的Python,而不是通过Anaconda开发的本地版本,因为Jupyter Python 3笔记本中的sys.path是不同的.另外,jupyter kernelspec list给出以下内容:

But Jupyter's python kernel seems to be pointing to a system version of Python rather than my local version through Anaconda, since the sys.path is different in a Jupyter Python 3 notebook. Also, jupyter kernelspec list gives the following:

Available kernels:
  ir         /usr/local/share/jupyter/kernels/ir
  matlab     /usr/local/share/jupyter/kernels/matlab
  python3    /usr/local/share/jupyter/kernels/python3

这似乎并不完全令人惊讶,因为 docs 在第1.5.5节:

This doesn't seem altogether surprising since the docs say in section 1.5.5:

默认情况下,内核规范将位于系统范围内的位置(例如/usr/local/share/jupyter/kernels).如果执行--user安装,则内核规范将位于JUPYTER_DATA_DIR位置.

By default, kernel specs will go in a system-wide location (e.g. /usr/local/share/jupyter/kernels). If doing a --user install, the kernel specs will go in the JUPYTER_DATA_DIR location.

出于个人理智和组织上的考虑,我希望在命令行中使用的Python版本与Jupyter中访问的Python版本相同.结果,我认为我应该做的就是更改python3的jupyter kernelspec列表,使其指向我想要的Anaconda python版本,即/home/.../software/anaconda3/bin/python.我的问题是:1)确实是针对我所陈述的首选项的最佳解决方案,2)我实际上如何更改python3的jupyter kernelspec条目?不确定是否会出现这种情况,但是我不想使用虚拟环境-我希望命令行和Jupyter的默认版本都是相同的Python版本.

For personal sanity and organization, I want the version of Python that I use in the command line to be the same that is accessed in Jupyter. As a result, I think that what I should do is change my jupyter kernelspec list for python3 so that it points to my desired Anaconda python version, i.e. /home/.../software/anaconda3/bin/python. My questions are: 1) is that indeed the best solution for my stated preferences, and 2) how do I actually change my jupyter kernelspec entry for python3? Not sure if this will come up, but I don't want to be using virtual environments--I want the default to be same version of Python across both the command line and Jupyter.

推荐答案

我最终将其重新发布到Jupyter Github问题页面,建议删除/usr/local/share/jupyter/kernels/python3.这样,Jupyter可以使用运行Jupyter本身的同一Python(即Anaconda)找到默认的Python内核,这对我有用.

I ended up reposting this to the Jupyter Github issues page, and was recommended to delete /usr/local/share/jupyter/kernels/python3. This allows Jupyter to find a default Python kernel using the same Python running Jupyter itself (i.e. Anaconda), and this worked for me.

您可以在Jupyter的Github页面上找到我的帖子,以及上述解决方案为何起作用的解释这里.

You can find my post on Jupyter's Github page as well as an explanation for why the above solution works here.

这篇关于更改Jupyter kernelspec以指向anaconda python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆