安装requests库,之前使用:pip install requests
结果没有sudo,导致失败
后面加了 sudo pipinstall requests
却提示失败,无法collect......
The directory '/home/bzy/.cache/pip/http' or its parentdirectory is not owned by the current user and the cache has beendisabled. 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 pipinstall requests
的报错信息,才知道要加上 -H
sudo -H pip installrequests
这样就好了。
-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 )