前言
为了在jupyter中使用pyTorch的虚拟环境,来记录一下怎么操作一、conda命令的使用
因为使用的是jupyter,所有就使用Anaconda Prompt来创建虚拟环境(也可使用virtualenv,不过没试过)
conda create -n 环境名 # 创建的环境在默认路径下,C盘位置不够使用下面命令
# 指定创建路径
conda create --prefix="D:\\python\\envs\\环境名" python=3.9.0
# 包的管理
conda install -n 某个环境 包名(=版本号)
conda uninstall -n 某个环境 包名
# 删除虚拟环境
conda remove -n 环境名 --all
二、切换到虚拟环境
conda activate 之前创建的虚拟环境名
三、安装需要的包
conda install jupyter
conda install ipykernel # 安装jupyter内核
# 添加虚拟环境到jupyter中
python -m ipykernel install --user --name 虚拟环境名 --display-name 在jupyter中显示的环境名称
四、移除jupyter中的虚拟环境
jupyter kernelspec remove 环境名