温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

jupyter的notebook内核如何配置

发布时间:2022-02-18 13:37:06 来源:亿速云 阅读:262 作者:iii 栏目:开发技术

本篇内容主要讲解“jupyter的notebook内核如何配置”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“jupyter的notebook内核如何配置”吧!

我的 jupyter-bootbook 是在 ubuntu 下安装 anaconda 获得的,下面的命令在 Windows 下大部分可以运行,但略有差异。还是建议在 Linux 环境下做 AI 开发。

添加内核

创建一个新的虚拟环境,安装 python ipykernel

(base) fxyang@dl733:~$ conda create -n study python ipykernel

激活该环境

(base) fxyang@dl733:~$ conda activate study
(study) fxyang@dl733:~$

在激活的环境下,执行下面的命令添加内核

(study) fxyang@dl733:~$ python -m ipykernel install --user --name study
Installed kernelspec study in /home/fxyang/.local/share/jupyter/kernels/study

其中 study 是该环境对应内核在 notebook 中显示的名称,一般建议与虚拟环境名相同。

查看已有内核列表

(study) fxyang@dl733:~$ jupyter-kernelspec list
Available kernels:
  study      /home/fxyang/.local/share/jupyter/kernels/study
  python3    /home/fxyang/Software/anaconda3/envs/study/share/jupyter/kernels/python3

重命名内核

将 study 环境的 kernel 重命名为 study2

(study) fxyang@dl733:~$ cd /home/fxyang/.local/share/jupyter/kernels/study
(study) fxyang@dl733:~/.local/share/jupyter/kernels/study$ vim kernel.json
# 更改字段如下:
"display_name": "study2"

自此,notebook 核心如下图所示:

jupyter的notebook内核如何配置

注意:jupyter-notebook 的根目录取决于,执行 jupyter-notebook 命令的根目录。而且该命令只能在 base 环境下运行,因为 jupyter-notebook 工具安装在 base 环境下。

删除内核

(study) fxyang@dl733:~$ jupyter-kernelspec uninstall study
Kernel specs to remove:
  study                   /home/fxyang/.local/share/jupyter/kernels/study
Remove 1 kernel specs [y/N]: y
[RemoveKernelSpec] Removed /home/fxyang/.local/share/jupyter/kernels/study

Python3 这个核心指向当你激活的虚拟环境,一般都不会使用 base 环境作为开发环境,一个工程,一个环境。

到此,相信大家对“jupyter的notebook内核如何配置”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI