Python pip 的 -H 标志是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28619686/
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 03:31:46  来源:igfitidea点击:

What is the -H flag for pip?

pythonpip

提问by drevicko

When using sudo pip install ...with pip version 6.0.4 or greater, I get some warnings like:

使用sudo pip install ...pip 版本 6.0.4 或更高版本时,我收到一些警告,例如:

The directory '/home/drevicko/.cache/pip/log' or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.

目录“/home/drevicko/.cache/pip/log”或其父目录不属于当前用户所有,并且调试日志已被禁用。请检查该目录的权限和所有者。如果使用 sudo 执行 pip,您可能需要 -H 标志。

This warning appears to have been added in 6.0.4, but the -Hflag doesn't appear in the pip installdocsnor in the docs on pip's general options.

此警告似乎已在 6.0.4 中添加,但该-H标志未出现在pip install文档中,也未出现在pip 的常规选项的文档中。

So, what is the -Hflag and why do I need it when using sudo pip install ...?

那么,什么是-H标志,为什么在使用时需要它sudo pip install ...

采纳答案by Paul Thompson

The -H flag is actually for the sudocommand and not for pip. As taken from the docs

-H 标志实际上是用于sudo命令而不是用于 pip。从文档中获取

The -H (HOME) option requests that the security policy set the HOME environment variable to the home directory of the target user (root by default) as specified by the password database. Depending on the policy, this may be the default behavior.

-H (HOME) 选项请求安全策略将 HOME 环境变量设置为密码数据库指定的目标用户(默认为 root)的主目录。根据策略,这可能是默认行为。

A look at thisquestion might provide more insight into what could be happening.

看看这个问题可能会更深入地了解可能发生的事情。