pyenv is installed but the shell cannot find it
Command 'pyenv' not found, did you mean:Short answer
The shell finds pyenv only if its bin folder is on PATH. Either pyenv was never installed, or the three setup lines were not added to the file your shell reads at startup. Install it with the official installer, add the lines to .bashrc or .zshrc (and the login file if needed), then restart the shell.
Fix it fast
1Find out which cause you have
Check whether the folder exists at all. That separates 'not installed' from 'not on PATH'.
ls -d ~/.pyenv echo "$PATH" | tr ':' '\n' | grep pyenv echo "$SHELL"2Match what you see, then jump to its fix
- 1
ls: cannot access '/home/you/.pyenv': No such file or directorypyenv was never installedFix - 2
~/.pyenv exists, but pyenv is not in PATHThe setup lines are missing from your shell's startup fileFix - 3
pyenv works in a new terminal window but not over SSH or in a login shellLogin shells and SSH sessions read a different fileFix
- 1
What does the error look like?
Command 'pyenv' not found, did you mean:pyenv: command not found
Cause 1 of 3
pyenv was never installed
1Check
The README's automatic installer is the supported route on Linux, and it puts pyenv under ~/.pyenv.
ls -d ~/.pyenv2Fix
Run the automatic installer that the pyenv README recommends on Linux. Install Python build dependencies before the first pyenv install.
curl -fsSL https://pyenv.run | bash3Verify
The folder exists and the binary answers.
~/.pyenv/bin/pyenv --versionConfirmed by github.com
Cause 2 of 3
The setup lines are missing from your shell's startup file
1Check
pyenv needs PYENV_ROOT, its bin directory on PATH, and the init line. Look for them in the file your shell reads.
grep -n pyenv ~/.bashrc ~/.zshrc ~/.profile 2>/dev/null2Fix
Add the three lines for your shell (bash shown). For zsh put them in ~/.zshrc and use pyenv init - zsh.
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init - bash)"' >> ~/.bashrc3Verify
Restart the shell, then run pyenv.
exec "$SHELL"
pyenv --versionConfirmed by github.com
Cause 3 of 3
Login shells and SSH sessions read a different file
1Check
The README says to put the same lines in ~/.profile, ~/.bash_profile or ~/.bash_login as well, for login shells. It also warns that if BASH_ENV points at .bashrc, the eval line belongs in .bash_profile.
echo "$BASH_ENV"; ls -a ~ | grep -E 'profile|bash_login'2Fix
Repeat the three lines in the login file your shell actually uses.
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init - bash)"' >> ~/.profile3Verify
Open a fresh login shell.
bash -l -c 'pyenv --version'Confirmed by github.com
How do I stop it coming back?
- Install pyenv per user, not with sudo.
- After editing a startup file, restart the shell with exec "$SHELL" instead of opening a half-configured one.
- Install the Python build dependencies before pyenv install, as the README asks.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Servers
apt-get does not exist on this EC2 instance
sudo: apt-get: command not found
apt-get belongs to Debian and Ubuntu.
2 causes, each with a fixServers
bash warns that it cannot change the locale after you log in to a server
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
The shell was told to use a locale that is not built on the server.
3 causes, each with a fixServers
Syntax error: redirection unexpected when a Bash script runs under sh
script.sh: 12: Syntax error: redirection unexpected
The operators <<< (here-string) and &> are Bash features.
3 causes, each with a fixServers
ping is missing inside a Docker container
sh: 1: ping: not found
Base images such as ubuntu are minimal, so ping is simply not installed.
2 causes, each with a fixServers
Running ps inside a container says command not found
bash: ps: command not found
Slim Debian and Ubuntu images do not ship the procps package, and ps comes from procps.
2 causes, each with a fixServers
GitHub Actions step fails writing to GITHUB_OUTPUT
Error: Invalid format '...'
The runner reads GITHUB_OUTPUT line by line, and every entry must be name=value or a name<<DELIMITER block.
3 causes, each with a fix