Ubuntu sudo: pip:找不到命令

Ubuntu sudo: pip:找不到命令

解决过程

1.vi命令编辑 /etc/sudoers 文件,将 Defaults env_reset ,改为 Defaults !env_reset

sudo vi /etc/sudoers

Defaults	!env_reset

2.vi命令编辑.bashrc文件

sudo vi ~/.bashrc

在.bashrc文件中添加

alias sudo='sudo env PATH=$PATH'

添加完之后,再source一下

source ~/.bashrc

3.试试效果

fong@fong:~$ sudo pip install -U pip
The directory '/home/fong/.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.
The directory '/home/fong/.cache/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.
Requirement already up-to-date: pip in ./anaconda3/lib/python3.5/site-packages (18.0)
fong@fong:~$ 

4.发现有两个用户权限的warning。提示是pip目录的属主不是sudo的root用户。如果必须用sudo pip,更改pip目录属主即可:

sudo chown root /home/fong/.cache/pip/http
sudo chown root /home/fong/.cache/pip

再试试

fong@fong:~$ sudo pip install -U pip
Requirement already up-to-date: pip in ./anaconda3/lib/python3.5/site-packages (18.0)
fong@fong:~$ 

Yes,You are done!

评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值