在Python 项目中有个经常用到的命令,那就是pip , 本文将详细的讲解pip 的使用指南,内容涵盖安装、使用技巧、虚拟环境管理及常见问题解决。
一、pip 核心概念
- Python 包管理器:用于安装和管理 Python 包(PyPI 仓库)。
- 功能:
- 安装、卸载、升级第三方库。
- 管理依赖关系(需结合其他工具如
requirements.txt
)。
- 适用场景:
- 纯 Python 项目依赖管理。
- 轻量级开发,无需复杂环境隔离。
二、基础操作
1. 安装包
# 安装最新版本
pip install requests
# 安装指定版本
pip install numpy==1.21.0
# 安装开发版本(Git仓库)
pip install git+https://github.com/user/repo.git
2. 卸载包
pip uninstall requests
3. 更新包
pip in