I am following https://amaral.northwestern.edu/resources/guides/pyenv-tutorial to install pyenv.
I installed pyenv and update the .bash_profile
as
export PYENV_ROOT=/usr/local/pyenv/
export PATH="/usr/local/pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
I added in my user and root
, both can access pyenv
without any issue.
When I run sudo pyenv
it gives error.
$ sudo pyenv
sudo: pyenv: command not found
But when I run after login to that user, it works fine.
$ 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
I also move that .bash_profile
content to .bashrc
of /root/
but still it gives same error.
How to say sudo
that, when you run, please load .bashrc
or .bash_profile
first.
sudo -i pyenv
do what you want? – Relegateansible
let me see how can I passsudo -i
in ansible command module. – Commode