首页 > 技术文章 > jupyter notebook 实现虚拟环境运行代码

ache 2021-05-19 14:27 原文

  1. 首先是在base环境安装 ipykernel
pip  install  ipykernel
  1. 将虚拟环境注册到 jupyter notebook 中
python -m ipykernel install --user --name 'name1' --display-name 'name2'

其中 name1 为环境名字,name2 为要显示的名字。例如我的如下,显示默认名字。

python -m ipykernel install --user --name tf2-gpu
  1. 在 jupyter notebook 中切换
    创建文件时选择:

 

 在 kernel 中选择:

 

 至此完成了 jupyter notebook 使用虚拟环境。

 

有参考网上教程,此处记录为了方便自己查看,以及记录下学习。

 

推荐阅读