What is the -H flag for pip?

2019-03-17 04:12发布

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

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.

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

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

标签: python pip
1条回答
地球回转人心会变
2楼-- · 2019-03-17 04:45

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

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.

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

查看更多
登录 后发表回答