python - 如何删除使用旧版本 Python/Pip 安装的软件包?
问题描述
我的包遇到问题,我用 Python 3.7 安装了一个包,而我计算机中的当前 Python 版本是 3.9。所以我无法卸载或更新给定的包。
ζ pip3 install --upgrade youtube-dl
Requirement already satisfied: youtube-dl in /usr/local/lib/python3.9/site-packages (2021.4.7)
Collecting youtube-dl
Downloading youtube_dl-2021.4.26-py2.py3-none-any.whl (1.9 MB)
|████████████████████████████████| 1.9 MB 551 kB/s
Installing collected packages: youtube-dl
Attempting uninstall: youtube-dl
Found existing installation: youtube-dl 2021.4.7
Uninstalling youtube-dl-2021.4.7:
Successfully uninstalled youtube-dl-2021.4.7
Successfully installed youtube-dl-2021.4.26
WARNING: You are using pip version 21.0.1; however, version 21.1.1 is available.
You should consider upgrading via the '/usr/local/opt/python@3.9/bin/python3.9 -m pip install --upgrade pip' command.
ζ youtube-dl --version
2021.04.01
ζ which pip3
/usr/local/opt/python@3.9/bin/pip3
ζ which youtube-dl
/Library/Frameworks/Python.framework/Versions/3.7/bin/youtube-dl
怎么能
解决方案
要解决此问题,您需要做的是从安装包的版本导航到 Pip,在本例中为 3.7,使用此 pip 卸载或更新包。
ζ cd /Library/Frameworks/Python.framework/Versions/3.7/bin/
ζ ./pip3 uninstall youtube-dl
Found existing installation: youtube-dl 2021.4.1
Uninstalling youtube-dl-2021.4.1:
Would remove:
/Library/Frameworks/Python.framework/Versions/3.7/bin/youtube-dl
/Library/Frameworks/Python.framework/Versions/3.7/etc/bash_completion.d/youtube-dl.bash-completion
/Library/Frameworks/Python.framework/Versions/3.7/etc/fish/completions/youtube-dl.fish
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/youtube_dl-2021.4.1.dist-info/*
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/youtube_dl/*
/Library/Frameworks/Python.framework/Versions/3.7/share/doc/youtube_dl/README.txt
/Library/Frameworks/Python.framework/Versions/3.7/share/man/man1/youtube-dl.1
Proceed (y/n)? y
Successfully uninstalled youtube-dl-2021.4.1
现在您可以在系统中安装包含最新 Python 的软件包
ζ pip3 install youtube-dl
这个答案还提供了一种处理多个python版本的方法
推荐阅读
- ionic-framework - Ionic 5 操作表文本不接受 transloco
- javascript - Javascript | 为什么它在一开始就起作用了两次
- python - 有括号的方法和没有括号的方法有什么区别?
- javascript - 为什么这个不为空的数组返回为空?
- kubernetes - Azure Kubernetes 服务 (AKS) - Pod 重启警报
- javascript - 在 Vuetify 数据表中禁用默认分页?
- linux - 用于对多个输入一一执行单个命令的 Bash 脚本
- python - 不是二进制交叉熵中的二进制地面实况标签?
- javascript - JavaScript 搜索栏弹出窗口
- r - 使用 ts() 函数在 R 中具有 1 分钟频率的时间序列