Ubuntu 18.04使用sudo pip3报错

在使用sudo pip3 install python库的时候出现如下警告:

The directory '/home/lzhu/.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.

解决方案如下:

将 sudo pip3 install 改为 sudo -H pip3 install