conda常用命令

1
2
conda info --envs # 查看anaconda中所有环境
conda list # 查看当前环境下有哪些包

添加新环境

1
2
3
4
5
6
conda create -n xxx # 创建新的环境,不指定python版本;xxx为环境名
conda create -n xxx python=3.8 # 可指定python版本
conda activate xxx # 激活xxx环境
conda deactivate # 退出xxx环境,返回base
conda uninstall -n xxx --all # 删除环境
conda install ipykernel # 添加进jupyter notebook环境 vscode中可以识别就可以

忽略warning信息

1
2
import warnings
warnings.filterwarnings("ignore")

将新环境添加进Jupyter Notebook

1
2
3
4
jupyter kernelspec list # 查看安装了哪些虚拟环境kernel
pip install --user ipykernel # 安装ipykernel
python -m ipykernel install --user --name=xxx # 将环境加入jupyter
jupyter kernelspec uninstall xxx # 删除指定的kernel