Skip to content

Instantly share code, notes, and snippets.

@crazyoptimist
Last active December 6, 2024 13:54
Show Gist options
  • Save crazyoptimist/12a7bb9d586c5c23be3d1a7a04b208db to your computer and use it in GitHub Desktop.
Save crazyoptimist/12a7bb9d586c5c23be3d1a7a04b208db to your computer and use it in GitHub Desktop.
Install pyenv on Ubuntu/Debian
#!/bin/bash
# Install dependencies for pyenv(because pyenv compiles python from the source)
## Debian / Ubuntu
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl
## Fedora
# sudo yum install gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel
## Arch
# yay -Sy tk pyenv
## Mac
# brew install openssl readline sqlite3 xz zlib
# sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
# Install pyenv
curl https://pyenv.run | bash
# Use pyenv to manage multiple versions of python
## Check available (latest) python versions
pyenv install --list | grep " 3\.12"
## Install a python version in need
# pyenv install 3.12.2
## Check installed versions
# pyenv versions
## Set a version as global
# pyenv global 3.12.2
# Boom! Done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment