当前位置:   article > 正文

Ubuntu sudo: pip:找不到命令_sudo: pip:找不到命令

sudo: pip:找不到命令

Ubuntu sudo: pip:找不到命令

解决过程

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

sudo vi /etc/sudoers

Defaults	!env_reset
  • 1
  • 2
  • 3

2.vi命令编辑.bashrc文件

sudo vi ~/.bashrc
  • 1

在.bashrc文件中添加

alias sudo='sudo env PATH=$PATH'
  • 1

添加完之后,再source一下

source ~/.bashrc
  • 1

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:~$ 
  • 1
  • 2
  • 3
  • 4
  • 5

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

sudo chown root /home/fong/.cache/pip/http
sudo chown root /home/fong/.cache/pip
  • 1
  • 2

再试试

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

Yes,You are done!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/793277
推荐阅读
相关标签
  

闽ICP备14008679号