首页 > 解决方案 > 如何删除使用旧版本 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

怎么能

标签: pythonpip

解决方案


要解决此问题,您需要做的是从安装包的版本导航到 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版本的方法


推荐阅读