pip原始版本 9.0.1

tangzhe@tangzhe:~ pip --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

更新pip至最新版本

pip install --upgrade pip

再查看pip版本时出现WARNING

tangzhe@tangzhe:~ pip --version
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.
pip 21.3.1 from /home/tangzhe/.local/lib/python3.6/site-packages/pip (python 3.6)

提示内容显示,如果在pip前面加上"python -m "就不会出现警告,试了下,确实如此

tangzhe@tangzhe:~$ python -m pip --version
pip 21.3.1 from /home/tangzhe/.local/lib/python3.6/site-packages/pip (python 3.6)

但其实问题没有解决,而且这样很麻烦(当然也可以修改alias,让pip指向python -m pip)

在网上查了下,有建议通过"python -m "强制重新安装pip

python -m pip install --upgrade --force-reinstall pip

但是我这边pip --version的时候还是会出现WARNING - -!

强制重新安装时也出现了WARNING,而且这个WARNING指出了问题!!!

  WARNING: The scripts pip, pip3 and pip3.6 are installed in '/home/tangzhe/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

将 '/home/tangzhe/.local/bin' 添加到 PATH 后就不会报错了

* 其实一开始pip --version的两个路径就说明了问题

更新前的pip在 "/usr/lib/python3/dist-packages", 更新后的pip在 "/home/tangzhe/.local/lib/python3.6/site-packages/pip",而后一个路径并不在PATH里面!

【总结】pip相关的文章

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐