<h2>How to use pyenv with another user?</h2>
For example, If I have installed pyenv in user test's environment, I could use pyenv when i login as test.
However, how could i use pyenv when I login as another user, such as root?
Even if you did this, I'd strongly discourage it. Root can access pretty much everyone's home directory, but the nuances of adding programs to the PATH that the root user doesn't <em>technically</em> own can be detrimental at best - might lead to a few root services not working properly, and actively insecure at worst.
There's <em>literally</em> nothing wrong with installing your own copy of pyenv as another user. There's no pain involved and there's not much sense to do it any other way.
If you are on a Mac I'd strongly discourage trying to follow the above advice. Trying to install a personal copy of pyenv using homebrew won't work. What you can do is to set
~/.bashrc so that your pyenv data is local, even if pyenv itself is shared. You will need to install your own copies of every python version you want, but fortunately disk space is cheap.