Pip、Conda指令合集(己用)

一、Pip

#清华:https://pypi.tuna.tsinghua.edu.cn/simple
#豆瓣:http://pypi.douban.com/simple/

Wheel轮子下载库
本地wheel文件安装 whl文件可以去https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyhook离线下载到本地

https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyhook

常用指令

# 安装python包
pip install 包名

# 指定版本号
pip install 包名==版本 
pip install 包名>=2.22, <3
pip install 包名!=2.22

# 指定镜像源安装
pip install -i url 包名  # 其中国内镜像源( url ) 可以是清华、中科大、豆瓣等
#清华:https://pypi.tuna.tsinghua.edu.cn/simple
#豆瓣:http://pypi.douban.com/simple/

# 本地wheel文件安装 whl文件可以去https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyhook离线下载到本地
pip install 包名.whl

# github仓库中安装
pip install git+包的github地址

# 更新python库
pip install 包名 -U

# 查看可提供安装的版本
pip install 包名==lemon

# 查看已经安装的python库
pip list
# 查询当前环境可升级的包
pip list -o

# 查看python库的信息
pip show 包名
pip show 包名 -f

# 卸载包
pip uninstall 包名

# 导出依赖包列表 freeze命令, 复用包很方便
pip freeze > requirements.txt  # 获取当前环境安装python库的版本信息,导入到txt文件中
# 从依赖包中安装
pip install -r requirements.txt

# 将python库制作成wheel文件,可以提供给他人用.whl文件,先安装wheel库
pip install wheel
# 特定python库制作成wheel文件
pip wheel --wheel-dir DIR some-package[==version] # 其中,DIR是保存文件的路径,比如users/lemon/Downloads

# 根据依赖包信息,制作wheel文件
pip wheel --wheel-dir DIR -r requirements.txt

二、Conda

2.1 添加源

换源:
在anaconda的cmd终端,分别输入如下三行命令:

#清华源
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 --add  channels https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/
conda config --add  channels  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add  channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add  channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add  channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add  channels

#中科大源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

2.2删除源

删除添加的镜像源(如果后边不添加网址,则默认删除所有已安装的国内镜像源)

conda  config --remove-key channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

2.3 常用命令


#常用命令:---------------------------------------------------------------------------
conda list             // 显示已安装的python包,如果是通过pip安装的包,不会显示
conda search xxx       // 搜索python包
conda install xxx=1.2  // 安装指定安装包版本
conda install D:xxx    // 安装本地python包(绝对路径)
conda env list         // 查看当前存在哪些虚拟环境
conda create -n pytorch python=3.7 // 创建虚拟环境pytorch,python版本为3.7
conda activate pytorch         // 启用虚拟环境
conda deactivate               // 退出当前虚拟环境
conda remove -n pytorch --all  // 删除虚拟环境
conda info                     // 显示相关信息
conda update conda             // 更新conda

conda虚拟环境名字:可以通过克隆旧的,再删除旧的实现改名。

conda create --name new(新环境名) --clone  old(旧环境名)

删除旧的环境

conda env remove --name  旧环境名
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

驭风少年君

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值