pyenv

pyenv is a popular command-line tool that helps Python developers manage multiple Python versions efficiently. If you work on various Python projects, each requiring a different version of Python, pyenv keeps your workflow smooth by allowing you to install, switch, and manage Python versions effortlessly.

https://github.com/pyenv/pyenv

To install, run

curl -fsSL https://pyenv.run | bash

Edit ~/.profile

vi ~/.profile

add at the end of the file

export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init - bash)"

Install build dependency

on Ubunutu, run

apt update; apt install make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl git libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

For other operating systems, see

https://github.com/pyenv/pyenv/wiki#suggested-build-environment

Install a specific Python version

pyenv install 3.10.7

Set the global Python version:

pyenv global 3.10.7

Set a local version for a project:

pyenv local 3.9.13

To list all installed python versions, run:

pyenv versions

Back to Python

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *