在mac下使用pip install命令时,有时会出现下面的黄色警告:
The directory ‘/User/xxx/Library/xxx/pip’ 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却报出这样的警告。
这是由于你可能无意中在你的电脑上用sudo安装了 “virtualenv”,这样的话就会让所有的python包被改为root权限,而你作为一般用户无法对文件操作。我们可以用下面的命令来将文件权限改会一般用户
在terminal中输入
sudo chown -R username /Users/username/Library/xxx/pip
其中,username 是你的电脑用户名,后面的地址是黄字中的报错地址,复制过来就可以
阅读英文不易,如果解决了你的问题,请帮我点个赞吧