Post

Install pyenv on Linux Fedora

Install pyenv on Linux Fedora

What is pyenv?

pyenv is a powerful tool designed for managing multiple versions of Python on Unix-like systems, including Linux and macOS. It allows developers to easily install, switch between, and manage different Python versions without requiring administrative privileges.

pyenv Installation

  1. Install the required dependencies:
1
2
sudo dnf builddep python3
sudo dnf install "@Development Tools" zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel findutils
  1. Install pyenv using the automatic installer:
1
curl https://pyenv.run | bash
  1. Add the following lines to your ~/.bashrc file:
1
2
3
4
5
bash
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
  1. Restart your shell or run source ~/.bashrc to apply the changes.

  2. You can now install and set Python versions using pyenv:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# View all available versions with this command
pyenv install -l

# You can now install multiple Python version via pyenv, for example:
pyenv install 3.10.16
pyenv install 3.13.1

# List all Python versions available to pyenv
pyenv versions

# Check the global Python version
pyenv global

# Set the global python version using the pyenv command
pyenv global 3.10.16
pyenv global

You liked this blog post? Interested in coding together? Feel free to contact me.

This post is licensed under full copyright by the author.