Pyenv builds Python from source, which means you’ll need build dependencies to actually use it. The build dependencies vary by platform. If you are on Ubuntu/Debian and want to install the build dependencies, you could use the following:
After you’ve installed the build dependencies, you’re ready to install pyenv itself. We recommend using the pyenv-installer project:
curl https://pyenv.run | bash
At the end of the installation you will see something similar to:
WARNING: seems you still have not added 'pyenv' to the load path.
# Load pyenv automatically by adding
# the following to ~/.bashrc:
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Follow the instructions that will appear to add the paths to your /.bashrc file and then start a new shell session.:
exec "$SHELL" # Or just restart your terminal
This command will show a list of Python versions:
pyenv install --list
Now let's install the latest Python version (3.8.5 as of this writing):
Now that Python 3 is installed through pyenv, we want to set it as our global default version for pyenv environments:
Run this command to see the system Python's version after the change: