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
Warning: pip is being invoked by an old script wrapper
提问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 list
to 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 pip
worked for me. You can force a reinstall of pip
with:
我遇到了同样的问题,但在 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 xxx
in emergency case:
通过 Pytharm 将 pip 更新到 20.1.x 版本后,我遇到了同样的问题。我找到了一种方法来确保您可以pip install xxx
在紧急情况下使用:
- Just open the folder containing pip (e.g.
C:\Program Files\Python37\Lib
in my win10 laptop) - You may find two folders separately belongs to the old version pip and newly installed pip (e.g.
./pip19_xxx
for your old one and./pip
for the newly installed one - Delete the folder of the new version pip (e.g.
./pip
) - (IF NECESSARY) Change environment PATH in windows10
- Test
pip install xxx
orpython -m pip install xxx
incmd
, it should work by now
- 只需打开包含 pip 的文件夹(例如
C:\Program Files\Python37\Lib
在我的 win10 笔记本电脑中) - 您可以分别找到两个文件夹属于老版本点子和新安装的PIP(如
./pip19_xxx
您的旧和./pip
新安装的一个 - 删除新版本pip的文件夹(例如
./pip
) - (如果需要)在 windows10 中更改环境路径
- 测试
pip install xxx
或python -m pip install xxx
在cmd
,它现在应该可以工作
回答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 pip
module you are invoking when you use the pip
command. for me, I found out that when I would update and modify the pip
command, it would update the pip
file on my ~/.local/bin
directory but when I would run it, it would default to the pip
command located in the /usr/local/bin
directory.
您可能希望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/bin
worked 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 警告。让我知道这是否有帮助。