
1、查看安装库版本等信息
pip show:在命令行中直接运行 pip show requests 命令,可以显示该包的详细信息,包括版本号、作者和依赖关系等。
pip show requests
运行 pip list 命令可以列出所有已安装的包及其版本信息。
Python 代码查询获取版本号:
在 Python 代码中,你可以导入 requests 模块后,通过访问其 __version__ 属性来获取版本号。
import requests
print(requests.__version__)

2、安装库
pip install:安装命令,例如 pip install requests==<version>。
pip install requests==2.32.5
要使用 pip 安装指定版本的 requests 库,requests 可换为你的具体库。

3、卸载库
pip uninstall:卸载命令。
pip uninstall requests
在命令行中输入 pip uninstall requests,系统会提示确认卸载,输入 y 并按回车键确认即可完成卸载。如果希望跳过确认提示自动卸载,可以添加 -y 参数:
pip uninstall requests -y
多 Python 环境处理: 如果你有多个 Python 版本,可以根据需要使用:
pip3 uninstall requests
python3.8 -m pip uninstall requests

4、验证安装或卸载是否成功
验证卸载结果,卸载完成后,可以通过以下方式验证:
- 运行
pip show requests,如果没有返回信息则说明卸载成功。




