Ubuntu环境下解决‘ pip is being invoked by an old script wrapper. ...‘问题

        当我们使用pip需要更新时,会提示如下警告:

You are using pip version 9.0.1, however version 19.2.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

然而,使用提示的命令更新pip之后,每次安装模块时,会提示:

WARNING: pip is being invoked by an old script wrapper. This will fail in a future 
version of pip. Please see https://github.com/pypa/pip/issues/5599 for advice on 
fixing the underlying issue. To avoid this problem you can invoke Python with 
'-m pip' instead of running pip directly.

        网上的很多答案都是使用 python -m pip install XXX 进行安装,这种安装方式比较麻烦,并没有解决问题的本质。出现改问题的原因主要是安装pip与更新pip的方式不匹配。当ubuntu系统不存在pip时,会提示使用 sudo apt install python3-pip 进行pip的安装,而更新是基于Python的方式进行管理,即 python -m pip install --upgrade pip 。

        为了方便的进行pip的管理,可依靠python进行pip的安装,可参考pip说明文档进行安装。具体有两种方式:

1. python版本为3.10时,可执行

python -m ensurepip --upgrade

2. 利用get-pip.py文件进行安装

# 下载get-pip.py文件
wget https://bootstrap.pypa.io/get-pip.py

# 在包含get-pip.py文件的目录下
python get-pip.py

上一篇:uni.getUserProfile报错:fail can only be invoked by user TAP gesture


下一篇:A Parser-blocking, cross-origin script is invoked via document.write. This may be blocked by the bro