在操作过程中意外取消了 python 的 "pip" 升级,现在 pip 出现故障
Accidentally cancelled python's "pip" upgrade in the middle of the operation now pip is malfunctioning
我试图通过命令行更新 python 的 pip 命令,但不小心按下了 ctrl+c,这取消了升级过程。
我一意识到发生了什么,就尝试重新运行命令 python -m install --upgrade pip
,但我得到了这个错误代码:
(Currently running python 3.8.3) on Windows 10 Home
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\__main__.py", line 29, in <module>
from pip._internal.cli.main import main as _main
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 21, in <module>
from pip._vendor.packaging.utils import canonicalize_name
ModuleNotFoundError: No module named 'pip._vendor'
有什么方法可以解决这个问题还是我应该重新安装 python?除了 requests
库之外,我没有安装额外的 pip 库。
您可以按照 this 指南进行操作。我也在这里描述步骤:
- 找到您的 python 所在的位置。在 Windows 中,它可能位于类似于
C:\Users\<your-name>\AppsData\Local\Programs\Python\Python38-<minor-version>
的路径中
- 将get-pip.py脚本下载到Python所在的目录。复制内容粘贴到同名文件即可
- 打开终端(或 PowerShell)并将目录更改为 Python 所在的目录。
- 运行脚本如下:
python get-pip.py
- 通过执行验证安装:
pip -V
我试图通过命令行更新 python 的 pip 命令,但不小心按下了 ctrl+c,这取消了升级过程。
我一意识到发生了什么,就尝试重新运行命令 python -m install --upgrade pip
,但我得到了这个错误代码:
(Currently running python 3.8.3) on Windows 10 Home
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\__main__.py", line 29, in <module>
from pip._internal.cli.main import main as _main
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\HP\AppData\Local\Programs\Python\Python38\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 21, in <module>
from pip._vendor.packaging.utils import canonicalize_name
ModuleNotFoundError: No module named 'pip._vendor'
有什么方法可以解决这个问题还是我应该重新安装 python?除了 requests
库之外,我没有安装额外的 pip 库。
您可以按照 this 指南进行操作。我也在这里描述步骤:
- 找到您的 python 所在的位置。在 Windows 中,它可能位于类似于
C:\Users\<your-name>\AppsData\Local\Programs\Python\Python38-<minor-version>
的路径中
- 将get-pip.py脚本下载到Python所在的目录。复制内容粘贴到同名文件即可
- 打开终端(或 PowerShell)并将目录更改为 Python 所在的目录。
- 运行脚本如下:
python get-pip.py
- 通过执行验证安装:
pip -V