09 July 2025

Installing PyEnv on Raspberry Pi

Earlier I detailed the steps for installing PyEnv on Linux, but there are some small changes for doing the same on Raspberry Pi, so for my reference and the reference of anyone else, I thought I'd mention it the way Sam Westby did, but thought I'd automate the process by creating a script which even adds the necessary lines to bashrc.

#!/usr/bin/env bash

echo "Proceeding with installing PyEnv"

curl https://pyenv.run | bash

#Add environment variables to bashrc

echo "export PYENV_ROOT='$HOME/.pyenv'" >> ~/.bashrc

echo "[[ -d $PYENV_ROOT/bin ]] && export PATH='$PYENV_ROOT/bin:$PATH'" >> ~/.bashrc

echo "eval '$(pyenv init - bash)'" >> ~/.bashrc

#Restart the terminal to make bashrc changes effective

exec $SHELL

#Install other required packages

sudo apt-get install -y libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libgdbm-dev lzma lzma-dev tcl-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev wget curl make build-essential openssl

pyenv update

pyenv install --list

pyenv install 3.12.10

pyenv global 3.12.10



No comments: