欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ubuntu / xubuntu conda/pyenv need permission, but sudo conda :command not found

程序员文章站 2022-07-12 13:42:01
...

安装conda ,pyenv 创建python环境时 有时候需要 permission ,

但是默认是安装在用户系统环境下,sudo conda :command not found

method 1 : 授予 路径权限

 sudo chown -R ubuntu /home/ubuntu/anaconda3 
 sudo chmod -R +x /home/ubuntu/anaconda3  

​ /home/ubuntu/anaconda3 为 需要 权限 的 路径

method 2 添加到 sudo 路径中 使用 sudo command

To customize the default PATH variable for sudo session, open /etc/sudoers file with a text editor, and look for "secure_path". The value defined in "secure_path" will be used as the default PATH variable when you execute sudocommands.

So add any necessary path (e.g., /usr/local/bin) to "secure_path", and it will be passed to sudo commands.

Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

This change will be effective immediately.

  • sudo打开 sudo gedit /etc/sudoers ; gedit 是已经安装的文本编辑器

    ​ 如果 是xubuntu 默认编辑器 mousepad : sudo mousepad /etc/sudoers

  • 找到 Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

  • 添加 安装的 conda/bin 路径 ,注意: 分隔

  • 保存 立即就能用 sudo conda 了


refer :

  1. stackoverfllow
  2. Thx to chainly define-path-environment-variable-sudo-commands