Skip to content

Instantly share code, notes, and snippets.

@innat
Last active July 24, 2023 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save innat/fbbfa2ad87412ae9b886642015a0381f to your computer and use it in GitHub Desktop.
Save innat/fbbfa2ad87412ae9b886642015a0381f to your computer and use it in GitHub Desktop.

SOURCE

https://brain2life.hashnode.dev/how-to-install-pyenv-python-version-manager-on-ubuntu-2004

Install all required prerequisite dependencies

sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

Download and execute installation script

curl https://pyenv.run | bash

Add the following entries into your ~/.bashrc file:

# pyenv
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"

Restart your shell:

exec $SHELL

Validate installation:

pyenv --version

Uninstallation

Remove the ~/.pyenv folder

rm -fr ~/.pyenv

Delete the following entries from your ~/.bashrc file

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv virtualenv-init -)"

Restart your shell

exec $SHELL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment