在 Debian 系统中,“卸载 Python 包”通常有两种情况:用 apt 安装的 Python 包 和 用 pip 安装的 Python 包。下面分别说明。
Debian 官方仓库里的 Python 包通常以 python3-xxx 或 python-xxx 命名。
dpkg -l | grep python3
sudo apt remove python3-xxx
sudo apt purge python3-xxx
sudo apt autoremove
示例:
sudo apt purge python3-requests
sudo apt autoremove
pip3 show 包名 # 查看是否安装
pip3 uninstall 包名
source venv/bin/activate
pip uninstall 包名
pip3 freeze | xargs pip3 uninstall -y
⚠️ 会卸载当前环境所有 pip 包,慎用
dpkg -l | grep 包名 # apt 安装
pip3 show 包名 # pip 安装
❌ 不要卸载系统 Python(python3)
sudo apt remove python3
可能导致 apt、dpkg 等系统工具失效。
✅ 推荐做法:
如果你能告诉我:
我可以给你更精确的命令。