Skip to content

Install pyenv

Victoriano edited this page Feb 22, 2023 · 2 revisions

Pyenv

git clone https://github.com/pyenv/pyenv.git ~/.pyenv

Add to bash profile

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
# .zshrc
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile

# .zshrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc

Add pyenv init to your shell

echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile

# .zshrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc

or add in file .zshrc

# pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
 eval "$(pyenv init -)"
fi

Restart your shell so the path changes take effect

exec "$SHELL"

Install Python versions into $(pyenv root)/versions

pyenv install 3.6.4

Install pyenv