您的位置:首页 > 运维架构 > Linux

pip,python,ubuntu,linux,..sudo 导致失败问题(sudo -H)

2017-04-27 16:36 686 查看
安装requests库,

之前使用 pip install requests

结果没有sudo,导致失败

后面加了 sudo pip install requests

却提示失败,无法collect……(好坑)

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

Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by ‘ReadTimeoutError(“HTTPSConnectionPool(host=’pypi.python.org’, port=443): Read timed out. (read timeout=15)”,)’: /simple/requests/

最后仔细看了下

sudo pip install requests

的报错信息

才知道要加上 -H

sudo -H pip install requests

这样就好了

-H, –set-home

Request that the security policy set the HOME environment

variable to the home directory specified by the target user’s

password database entry. Depending on the policy, this may

be the default behavior.

-H 将环境变数中的 HOME (家目录)指定为要变更身份的使用者家目录(如不加 -u 参数就是系统管理者 root )
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐