pip包管理工具 基本使用

# 简介

  pip是一款包管理工具, 和apt, yum, brew功能类似

# 安装

wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py

python3 get-pip.py

# 将pip3加入环境变量

vi /etc/profile

export PATH=$PATH:/usr/local/bin

#重新加载环境变量文件

source /etc/profile

# 使用

pip3 --help # 可查看帮助信息
pip3 --version 或 pip3 -V # 查看版本信息
which pip3 # 查看安装位置

# 基本操作

安装包

pip3 install requests # 默认安装最先版包
pip3 install requests==1.1.0 # 安装指定版本包

批量安装包

pip install -r requirements.txt
requirements.txt 文件格式
Werkzeug==0.9.4
psycopg2==2.5.1

卸载包

pip3 uninstall requests 

更新某个包

pip3 install -U requests 

pip3 install --upgrade requests

查看已安装的所有包

pip3 list

显示包文件

pip show --files requests

# 配置pip安装源

国内源地址:  

  阿里云  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/

# mac
vi .pip/pip.conf # 打开配置文件 # 插入以下内容, 即可切换为豆瓣源 [global] trusted-host=pypi.douban.com index-url=http://pypi.douban.com/simple

# windows在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容如下
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

# 安装某个包时 指定源

pip3 install requests -i http://pypi.douban.com/simple

# 安装离线包

离线包下载地址 https://www.lfd.uci.edu/~gohlke/pythonlibs/

pip3 install xxxxxxx.whl # 安装

# 安装离线包, 报错: xxx.whl is not a supported wheel on this platform

 解决: 下载系统所支持的离线包即可

# 查看系统支持的安装包

python3 -c "import pip._internal;print(pip._internal.pep425tags.get_supported())"

 

这些就是pip的基本操作, 如有错误, 欢迎交流

 

 

转载于:https://www.cnblogs.com/mswei/p/11598340.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值