# Instalar Pyenv

<figure><img src="/files/S4uC1GAnGL5cysDyQKlg" alt=""><figcaption></figcaption></figure>

Instalamos dependencias

```sh
brew install openssl readline sqlite3 xz zlib tcl-tk
```

Ahora instalamos pyenv

```sh
brew install pyenv
```

Verificamos la version

```sh
pyenv --version
```

Instalamos version de python, podemos listar las opciones disponibles.

```sh
pyenv install --list
```

Ejemplo:

```sh
pyenv install 3.8.16
```

Establecer de forma global

```sh
pyenv global 3.8.16
```

Establecer de forma local

```sh
pyenv local 3.8.16
```

Listar las versiones de python instaladas, el \* marca la version seleccionada anteriormente.

```sh
$ pyenv versions
  system
* 3.8.16 (set by /Users/$user/.pyenv/version)
```

Añadimos al `.bash_profile`

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

Comprobamos que tenemos cargada la version elegida

```sh
$ python3 --version
Python 3.8.16
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blog.azagra.dev/macintosh/instalar-pyenv.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
