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

安装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 )

展开阅读全文

没有更多推荐了,返回首页