Python 警告:pip 正在被旧的脚本包装器调用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/60029215/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 21:00:12  来源:igfitidea点击:

Warning: pip is being invoked by an old script wrapper

pythonpip

提问by muyustan

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/5599for advice on fixing the underlying issue. To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.

警告: pip 正在被旧的脚本包装器调用。这将在未来版本的 pip 中失败。请参阅 https://github.com/pypa/pip/issues/5599以获取有关修复潜在问题的建议。为避免此问题,您可以使用“-m pip”调用 Python 而不是直接运行 pip。

When I directly type pip listto the terminal, I get the above warning. What does it mean exactly?

当我直接pip list在终端上输入时,我收到上述警告。它到底是什么意思?

Should I always use it as python3 -m pip list? (If I use it in that way, same output(list of packages) comes up without any warning)

我应该总是使用它python3 -m pip list吗?(如果我以这种方式使用它,相同的输出(包列表)会在没有任何警告的情况下出现)

p.s. : I am on ubuntu 18.10

ps:我在 ubuntu 18.10

回答by Asad Rauf

I faced the same issue but on Windows. Reinstalling pipworked for me. You can force a reinstall of pipwith:

我遇到了同样的问题,但在 Windows 上。重新安装pip对我有用。您可以强制重新安装pip

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

回答by Ankush Tiwari

You can use this procedure to revert back to older pip version

您可以使用此过程恢复到旧的 pip 版本

https://github.com/pypa/pip/issues/5599#issuecomment-414157896

https://github.com/pypa/pip/issues/5599#issuecomment-414157896

回答by Mino Zhao

I've encountered the same problem after I updated pip to 20.1.x version through Pytharm. I've found one way to ensure you can use pip install xxxin emergency case:

通过 Pytharm 将 pip 更新到 20.1.x 版本后,我遇到了同样的问题。我找到了一种方法来确保您可以pip install xxx在紧急情况下使用:

  1. Just open the folder containing pip (e.g. C:\Program Files\Python37\Libin my win10 laptop)
  2. You may find two folders separately belongs to the old version pip and newly installed pip (e.g. ./pip19_xxxfor your old one and ./pipfor the newly installed one
  3. Delete the folder of the new version pip (e.g. ./pip)
  4. (IF NECESSARY) Change environment PATH in windows10
  5. Test pip install xxxor python -m pip install xxxin cmd, it should work by now
  1. 只需打开包含 pip 的文件夹(例如C:\Program Files\Python37\Lib在我的 win10 笔记本电脑中)
  2. 您可以分别找到两个文件夹属于老版本点子和新安装的PIP(如./pip19_xxx您的旧和./pip新安装的一个
  3. 删除新版本pip的文件夹(例如./pip
  4. (如果需要)在 windows10 中更改环境路径
  5. 测试pip install xxxpython -m pip install xxxcmd,它现在应该可以工作

回答by Youknowme

Just use

只需使用

 python -m pip install [module_name] 

This will resolve warning issue

这将解决警告问题

回答by Ashim Pokharel

You can solve it by upgrading pip:

您可以通过升级来解决它pip

pip install --upgrade pip

回答by Uzoma Acholonu

Let me preface this by saying I am still very green with python and linux in general so I may be off base with my guidance here but I digress...

首先让我说我对 python 和 linux 还是很熟的,所以我在这里的指导可能会偏离基础,但我离题了......

You might want check the location of the pipmodule you are invoking when you use the pipcommand. for me, I found out that when I would update and modify the pipcommand, it would update the pipfile on my ~/.local/bindirectory but when I would run it, it would default to the pipcommand located in the /usr/local/bindirectory.

您可能希望pip在使用该pip命令时检查您正在调用的模块的位置。对我来说,我发现当我更新和修改pip命令时,它会更新pip~/.local/bin目录中的文件,但是当我运行它时,它会默认为pip位于/usr/local/bin目录中的命令。

run the command

运行命令

    pip install --upgrade pip

for me this command returned:

对我来说,这个命令返回:

Defaulting to user installation because normal site-packages is not writeable Requirement already up-to-date: pip in ./.local/lib/python3.6/site-packages (20.1.1)

默认为用户安装,因为普通的站点包不可写要求已经是最新的:pip in ./.local/lib/python3.6/site-packages (20.1.1)

Note the file location and version (in bold).

请注意文件位置和版本(以粗体显示)。

check your path variables and the default pip that executes default by running the these 2 commands respectively

通过分别运行这两个命令来检查您的路径变量和默认执行的默认 pip

    echo $PATH

and

    which pip

god willing, they'll be congruent otherwise you'll have to either alter your the path variable directories making sure that the directory for your desired pip module is first or you'll have to delete the pip file from the director that you dont want use (i.e. the directory that came up when you ran which pipif that is not the same as the directory listed when you updated pip)

上帝愿意,它们将是一致的,否则您必须更改路径变量目录以确保您所需的 pip 模块的目录是第一个,否则您必须从您不想要的导演中删除 pip 文件使用(即,当您运行which pip时出现的目录,如果该目录与您更新 pip时列出的目录不同)

For me, removing the pip files in the usr/local/binworked like a charm. Also check that the pip files that you want to use are referencing the correct version of python at the top of their scripts

对我来说,删除 pip 文件usr/local/bin就像一个魅力。还要检查您要使用的 pip 文件是否在其脚本顶部引用了正确版本的 python

#!/usr/bin/python3

# -*- coding: utf-8 -*-
import re
import sys

from pip._internal.cli.main import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

The other file originally referenced usr/bin/python (Python 2.7) instead of usr/bin/python3 (python 3.6.9) as I wanted initially.

另一个文件最初引用了 usr/bin/python (Python 2.7) 而不是我最初想要的 usr/bin/python3 (python 3.6.9)。

Like I said before, I am just getting started with linux and python so take this with a grain of salt. Nevertheless, I no longer get this pip warning after taking these steps. Let me know if this helps at all.

就像我之前说的,我刚刚开始使用 linux 和 python,所以请谨慎对待。尽管如此,在采取这些步骤后,我不再收到这个 pip 警告。让我知道这是否有帮助。