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

本文详细记录了解决在Mac环境下使用pip安装virtualenv时遇到的权限错误和PATH环境变量问题的过程,通过调整目录权限和使用sudo命令,最终成功安装virtualenv。

在安装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.youkuaiyun.com/LQMIKU/article/details/107300116

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值