jupyter切换不同的内核(虚拟环境)(anaconda 24.1.2)

jupyter切换不同的内核(anaconda 24.1.2)

主要的两条命令:

powershell 复制代码
conda install ipykernel
python -m ipykernel install --user --name '环境名称'                    

anaconda的版本号

powershell 复制代码
conda --version

实例:

一、首先可以看到已经创建的虚拟环境有两个:MechineLearnPytorch_GPU ,我们以 Pytroch_GPU为例。

powershell 复制代码
conda env list     # 查看anaconda中存在的虚拟环境

二、进入到Pytorch_GPU环境中

powershell 复制代码
conda activate '环境名称'       # 进入到需要的虚拟环境中去
conda deactivate                # 退出虚拟环境

三、然后安装ipykernel

powershell 复制代码
conda install ipykernel

输入Y进行安装

如果出现以下这种情况,表示没有写的权限,需要在Anaconda Prompt上右键,以管理员的身份运行,重新进行安装。

四、添加内核

powershell 复制代码
python -m ipykernel install --user --name '环境名称'

如果出现Installed kernelspec Pytorch_GPU in....,说明内核添加成功。

五、启动jupyter notebook

  1. 新建一个Notebook

  2. 会自动弹出选择kernel的窗口,点击下拉框。

  3. 选择刚刚添加的环境即可。

  4. 验证是否导入成功:

对已经创建的文件进行更换kernel:

  1. 点击菜单栏中的Kernel选项
  1. 选择最后一个Change Kernel选项
  1. 进行更换环境即可
相关推荐
小九九的爸爸3 小时前
前端想要入门Agent开发,要具备哪些Python基础?
python·agent·ai编程
阿耶同学4 小时前
手把手教你用 LangGraph 搭建三层嵌套 Agent 架构
python·程序员
花酒锄作田20 小时前
Pydantic校验配置文件
python
hboot20 小时前
AI工程师第四课 - 深度学习入门
pytorch·python·神经网络
ZhengEnCi1 天前
P2M-Matplotlib折线图完全指南-从数据可视化到趋势分析的Python绘图利器
python·matlab·数据可视化
ZhengEnCi1 天前
P2L-Matplotlib饼图完全指南-从数据可视化到图表定制的Python绘图利器
python·matlab
曲幽1 天前
你的REST接口还在“过度投喂”数据吗?——FastAPI + GraphQL实战避坑指南
python·fastapi·web·graphql·route·cors·rest·strawberry
用户8358086187911 天前
基于 Self-RAG 与列表级重排序的进阶 RAG 系统设计与实现
python
Warson_L2 天前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅2 天前
海天线算法的前世今生
python·计算机视觉