I would do the following 👇🏾:
## Step 1: Install Dependencies
Before installing Pyenv, install all the build dependencies shit:
```bash
sudo apt update
sudo apt install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libffi-dev liblzma-dev \
python3-openssl git
```
## Step 2: Install Pyenv
You can install Pyenv using the automatic installer. Run the following command in your terminal:
```bash
curl https://pyenv.run | bash
```
This command downloads and runs the Pyenv installer script, which sets up Pyenv and its associated tools.
## Step 3: Configure Your Shell
After installation, you need to add Pyenv to your shell's configuration file to ensure it loads every time you open a terminal. Depending on the shell you are using (e.g., Bash or Zsh), you will need to add the following lines to your `~/.bashrc` or `~/.zshrc` file:
```bash
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
```
To do this, you can use a text editor like `vim` or `nvim` in my case:
```bash
vim ~/.bashrc
```
Add the lines above at the end of the file, save, and exit.
## Step 4: Apply Changes
To apply the changes made to your shell configuration, run:
```bash
source ~/.bashrc
```
This command reloads the configuration file, making Pyenv available in your current terminal session.
## Step 5: Verify Installation
To confirm that Pyenv is installed correctly, run:
```bash
pyenv --version
```
If installed successfully, this command will display the version of Pyenv.
## Step 6: Install Python Versions
Now that Pyenv is set up, your friend can install different Python versions. For example, to install Python 3.10.0, they can run:
```bash
pyenv install 3.10.0
```
To set a global Python version, use:
```bash
pyenv global 3.10.0
```