jupyter notebook增加或删除kernel

jupyter notebook增加或删除kernel

今天用jupyternotebook来学习github上的一个项目,发现运行时报ModuleNotFoundError的错。检查了一下发现问题应该处在notebook的kernel上。因为我在电脑上装了不同的python环境,所以想要用特定的包就需要切换python环境。这里通过kernel实现。

增加kernel

第一步:打开cmd,进入想要使用的python环境下。在该环境下利用pip安装ipykernel

(python36) C:\Users\mark吐温>pip install ipykernel

第二步:安装完成后,输入jupyter kernelspec list命令查看当前的kernel。

(python36) C:\Users\mark吐温>jupyter kernelspec list
Available kernels:
  python3    d:\anaconda3\envs\python36\share\jupyter\kernels\python3

第三步:同样在该python环境下,输入以下命令创建新的kernel。(注意:‘–name python36’中的python36是你可以指定的kernel名字。)

(python36) C:\Users\mark吐温>python -m ipykernel install --name python36

第四步:查看当前kernel。可以看到已经增加了名为python36的kernel。

(python36) C:\Users\mark吐温>jupyter kernelspec list
Available kernels:
  python3     d:\anaconda3\envs\python36\share\jupyter\kernels\python3
  python36    C:\ProgramData\jupyter\kernels\python36

第五步:返回jupyter notebook,将kernel切换至python36。问题解决了!

删除kernel

在上述python环境下输入jupyter kernelspec remove python36命令。yes确认后即可删除相应的kernel。

(python36) C:\Users\mark吐温>jupyter kernelspec remove python36
Kernel specs to remove:
  python36              C:\ProgramData\jupyter\kernels\python36
Remove 1 kernel specs [y/N]: y
[RemoveKernelSpec] Removed C:\ProgramData\jupyter\kernels\python36

这时再次查看当前kernel时,就只剩最初的kernel了。

(python36) C:\Users\mark吐温>jupyter kernelspec list
Available kernels:
  python3    d:\anaconda3\envs\python36\share\jupyter\kernels\python3
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值