I follow the installation instruction here, and installed pyenv
under /home/mrcai/.pyenv
.
When I log in as mrcai
, pyenv
works pretty well as expected; but when I switch to root
and switch back as mrcai
, zsh
shows that it cannot find pyenv
.
/home/mrcai/.zshrc:114: command not found: pyenv
And $PATH
does not contain anything about .pyenv
, which is not the case under normal situation.
It seems the configuration in .zshrc
or .zprofile
did not work well. So could anyone please teach me how to solve this error permanently? Thank you!
Here is my configuration:
/home/mrcai/.zshrc
eval "$(pyenv init -)"
/home/mrcai/.zprofile
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
- OS: WSL 2 (Ubuntu-20.04) (The same problem also occurs under CentOS 8.5.)
- shell: zsh