conda和pip的常用语句

conda 安装/更新包

conda install geopandas=0.10.2 -c https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge -y
conda update geopandas -c https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge -y

jupyter 查看/添加/删除 环境的kernel信息

jupyter kernelspec list # 查看kernel
python -m ipykernel install --user --name 环境名 --display-name "环境名" # 添加kernel
jupyter kernelspec remove 名称 # 删除kernel

创建/删除/克隆 虚拟环境

conda create -n 虚拟环境名 python=3.7
conda create -n 虚拟环境名 python=3.7 -f requirements.txt  # 如果有requirements.txt文件
conda remove -n 虚拟环境名 --all
conda create --name B --clone A

重命名 虚拟环境

conda create --name B --clone A  # 先克隆新环境
conda remove --name A --all # 后删除旧环境

删除安装环境的缓存文件

conda clean --all

查看/重置/添加 源

conda config --show-sources
conda config --remove-key channels

添加源 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

备份/恢复 环境

conda env export > D:\env-name.yml # 备份环境到yml文件
conda env create -f D:\env-name.yml # 从yml文件恢复环境

环境已安装的包导出

conda list -e > D:/requirements.txt
pip freeze > D:/requirements.txt 或 
pip list --format=freeze > D:/requirements.txt

导入所需安装包

conda install --yes --file requirements.txt
pip install -r requirements.txt
posted @ 2021-03-30 17:12  lqqgis  阅读(119)  评论(0编辑  收藏  举报