pip包管理工具 基本使用-不止于python
简介
pip是一款包管理工具, 和apt, yum, brew功能类似
安装
1 | wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py |
使用
1 | pip3 --help # 可查看帮助信息 |
基本操作
安装包
1 | pip3 install requests # 默认安装最先版包 |
批量安装包
1 | pip install -r requirements.txt |
1 | requirements.txt 文件格式 |
1 | Werkzeug==0.9.4 |
卸载包
1 | pip3 uninstall requests |
更新某个包
1 | pip3 install -U requests |
查看已安装的所有包
1 | pip3 list |
显示包文件
1 | pip show --files requests |
指定安装路径
1 | pip install requests --target=/Users/Python/2.7/lib/python/site-packages |
配置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/
1 | # mac |
1 | [global] |
安装某个包时 指定源
1 | pip3 install requests -i http://pypi.douban.com/simple |
安装离线包
离线包下载地址 https://www.lfd.uci.edu/~gohlke/pythonlibs/
1 | pip3 install xxxxxxx.whl # 安装 |
# 安装离线包, 报错: xxx.whl is not a supported wheel on this platform
解决: 下载系统所支持的离线包即可
查看系统支持的安装包
1 | python3 -c "import pip._internal;print(pip._internal.pep425tags.get_supported())" |
这些就是pip的基本操作, 如有错误, 欢迎交流
作者:
胖胖不胖
版权声明:
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 不止于python
感谢您的支持,我会继续努力!
微信支付
支付宝