与sudo一起使用时未设置pyenv变量

时间:2018-05-22 18:46:40

标签: python bash sudo pyenv

我正在关注https://amaral.northwestern.edu/resources/guides/pyenv-tutorial安装pyenv。

我安装了pyenv并将.bash_profile更新为

export PYENV_ROOT=/usr/local/pyenv/
export PATH="/usr/local/pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

我添加了我的用户和root,两者都可以毫无问题地访问pyenv

当我运行sudo pyenv时,它会出错。

$ sudo pyenv
sudo: pyenv: command not found

但是当我在登录该用户后运行时,它运行正常。

$ sudo -i
# pyenv
pyenv 1.2.4
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
   commands    List all available pyenv commands
   local       Set or show the local application-specific Python version
   global      Set or show the global Python version
   shell       Set or show the shell-specific Python version
   install     Install a Python version using python-build
   uninstall   Uninstall a specific Python version
   rehash      Rehash pyenv shims (run this after installing executables)
   version     Show the current Python version and its origin
   versions    List all Python versions available to pyenv
   which       Display the full path to an executable
   whence      List all Python versions that contain the given executable

See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/pyenv/pyenv#readme

我还将.bash_profile内容移至.bashrc的{​​{1}},但仍会出现相同的错误。

如何说/root/,当您投放时,请先加载sudo.bashrc

0 个答案:

没有答案