学点conda命令吧 事半功倍

学点conda命令吧 事半功倍

1.python包管理器,大名鼎鼎

推荐安装miniconda3

1.1 win

Miniconda3-py37_4.8.3-Windows-x86_64.exe https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py37_4.8.3-Windows-x86_64.exe

1.2 linux

https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py37_4.8.3-Linux-x86_64.sh

1.3 macos

https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py37_4.8.3-MacOSX-x86_64.sh

1.4 其他

https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/

2.源

https://tuna.moe/oh-my-tuna 按说明下载脚本执行就切换pip更新源为清华源

学点conda命令吧 事半功倍_第1张图片

3.常用操作

3.1升级

conda update conda          #基本升级
conda update anaconda       #大的升级
conda update anaconda-navigator    //update最新版本的anaconda-navigator  

3.2基本命令

conda update -n base conda        #update最新版本的conda
conda create -n xxxx python=3.5   #创建python3.5的xxxx虚拟环境
conda activate xxxx               #开启xxxx环境
conda deactivate                  #关闭环境
conda env list                    #显示所有的虚拟环境
conda info --envs                 #显示所有的虚拟环境

3.3查看、卸载

conda list         #查看已经安装的文件包
conda list  -n xxx       #指定查看xxx虚拟环境下安装的package
conda update xxx   #更新xxx文件包
conda uninstall xxx   #卸载xxx文件包

3.4删除虚拟环境

conda remove -n xxxx --all   //创建xxxx虚拟环境

3.5清理(conda瘦身)

conda clean -p      //删除没有用的包
conda clean -t      //删除tar包
conda clean -y --all //删除所有的安装包及cache

3.6复制/重命名/删除env环境

//克隆oldname环境为newname环境
conda create --name newname --clone oldname 
//彻底删除旧环境
conda remove --name oldname --all     

3.7conda/pip install 下载速度慢

#显示目前conda的数据源有哪些
conda config --show channels
#添加数据源:例如, 添加清华anaconda镜像:
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 config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

3.8pip数据源管理

#显示目前pip的数据源有哪些
pip config list
pip config list --[user|global] # 列出用户|全局的设置
pip config get global.index-url # 得到这key对应的value 如:https://mirrors.aliyun.com/pypi/simple/

# 添加
pip config set key value
#添加数据源:例如, 添加USTC中科大的源:
pip config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple
#添加全局使用该数据源
pip config set global.trusted-host https://mirrors.ustc.edu.cn/pypi/web/simple

# 删除
pip config unset key
# 例如
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

#搜索
pip search flask  #搜素flask安装包

# 升级pip
pip install pip -U


阿里云                    http://mirrors.aliyun.com/pypi/simple/
中国科技大学         https://pypi.mirrors.ustc.edu.cn/simple/ 
豆瓣(douban)         http://pypi.douban.com/simple/ 
清华大学                https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学  http://pypi.mirrors.ustc.edu.cn/simple/

3.9pip常见命令

pip list #列出当前缓存的包
pip purge #清除缓存
pip remove #删除对应的缓存
pip help #帮助
pip install xxx #安装xxx包
pip uninstall xxx #删除xxx包
pip show xxx #展示指定的已安装的xxx包
pip check xxx #检查xxx包的依赖是否合适

你可能感兴趣的:(livingbody,paddlepaddle,conda,anaconda,pip,python)