Jump to content

Python

From Sinfronteras
Revision as of 14:33, 12 February 2026 by Adeloaleman (talk | contribs) (Created page with "==Install and manage multiple Python versions with pyenv== <span style="color:#5fe8e6;">★</span> Es lo que usan la mayoría de devs profesionales hoy. En Ubuntu 24.04, la forma más limpia, flexible y usada por la mayoría de desarrolladores para instalar varias versiones de Python en paralelo es pyenv. Permite: * Tener muchas versiones de Python instaladas a la vez * Cambiar de versión por proyecto * No romper el Python del sistema (muy importante en Ubuntu) Afte...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Install and manage multiple Python versions with pyenv

Es lo que usan la mayoría de devs profesionales hoy.

En Ubuntu 24.04, la forma más limpia, flexible y usada por la mayoría de desarrolladores para instalar varias versiones de Python en paralelo es pyenv. Permite:

  • Tener muchas versiones de Python instaladas a la vez
  • Cambiar de versión por proyecto
  • No romper el Python del sistema (muy importante en Ubuntu)


After installing pyenv, we can manage multiple python versions this way:

# Install system dependencies
sudo apt install -y build-essential curl git libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

# Install pyenv
curl https://pyenv.run | bash

vi ~/.bashrc
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"

eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

source ~/.bashrc

pyenv -v

# List available versions 
pyenv install --list

# Instalar python
# pyenv builds Python with pip, venv and ensurepip. ensurepip is a standard Python module whose only job is to make sure pip exists and works for a given Python installation. So, no further installation of python3-pip or python3.11-venv is required
pyenv install 3.10.14
pyenv install 3.11.14

# Ver versiones instaladas
pyenv versions

# Elegir versión global
pyenv global 3.11.14

# Elegir versión por proyecto. Eso crea un archivo .python-version en la carpeta
cd mi_proyecto
pyenv local 3.11.14

# Verificar
python --version
which python