Mac下导入virtualenv报错:its parent directory is not owned by the current user

在安装virtualenv时候

pip3 install virtualenv

首先报错 没有权限,然后我按照提示
Consider using the --user option or check the permissions.
运行了pip3 install virtualenv --user下面的报错

The script virtualenv is installed in ‘/Users/shendinghui/Library/Python/3.7/bin’ which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

在大神的指点下我接下来使用了sudo执行,sudo pip3 install virtualenv
接下来出现报错:

The directory ‘/Users/shendinghui/Library/Caches/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.
The directory ‘/Users/shendinghui/Library/Caches/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.

显示该目录或者其父级目录,当前用户没有权限
于是我给这个目录加上可写的权限,使用如下指令:

sudo chown -R yourUserName /Users/yourUserName/Library/Caches/pip/http

PS:
1、sudo是linux系统管理指令,是允许系统管理员让普通用户执行一些或者全部的root命令的一个工具,如halt,reboot,su等等;
2、上面指令中的目录是终端提示中的目录,应该更换为你的终端提示中的目录

执行以上指令后再次执行:

sudo pip install virtualenv 

到这里,成功导入啦!

在这里插入图片描述

参考https://blog.csdn.net/LQMIKU/article/details/107300116

你可能感兴趣的:(pip,mac,python)