type
status
date
Aug 1, 2023 11:58 AM
slug
summary
tags
category
icon
password
很多人在深度学习的过程可能需要在不同的虚拟环境中切换。这些环境不乏包括 tensorflow, pytorch, paddlex 等不同的框架。正常情况下,我们可以在 cmd 上使用 conda activate 虚拟环境名称来进行环境的切换。
本文将按步骤为 jupyter notebook 添加已配置好的虚拟环境。
具体流程:
- 查看当前 jupyter notebook 的环境:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fb58c008b-44ef-4e98-b3e4-a8508eb348e8%2F052d8e8e-e1c4-4504-b7f0-e4dc41f9bcce.png?table=block&id=bb6a2f04-4ca6-4834-be2a-f8b80aeb2062)
从上面可看出当前 jupyter 只有一个 python 3 的环境。
- 在 cmd 中切换至想要添加的环境:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fa1e1052b-231f-487d-8c25-bd64d91c3de9%2F4f72ba23-b498-4939-8117-fc517dbb9d59.jpeg?table=block&id=f13762d0-5bc6-44cf-89c2-d73d693ae8e2)
- 在当前的环境中安装好 ipykernel:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F6371c7a0-5745-4137-8c9e-a82cd4dc7060%2F051e4979-df01-4659-81e8-a1de8dc4ee3e.jpeg?table=block&id=a55bd478-ee34-453a-b2a4-41be1a6c3eda)
- 输入以下代码添加当前环境至 jupyter notebook:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fcf9a3344-3406-4d9e-a0c0-af427cda4063%2F0468ecc8-9c21-4bcc-a43f-1d7d360ce245.jpeg?table=block&id=b7647427-abc6-4f69-9ffd-ce6e6596eb7a)
5. 重启 jupyter notebook 即可看见新增的环境:
![notion image](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F71f54fde-2838-4716-a42f-c77e5daf4310%2F1789e8c6-b3af-4d2c-ae2d-1eaef5fb5a43.png?table=block&id=cef4aa7a-0950-4b89-af78-31448059a19c)
这样就完成了,以后就可以在 jupyter notebook 中自由切换环境了! > 本文由简悦 SimpRead 转码
补充-删除kernel name的方法