Python 3.9 install on Raspberry PI OS

This Tutorial is to Be used at your Own Risk make sure you Back up your Home Assistant Files and any other files you don’t want to lose Before Starting. it is easy to break it takes time Rebuilding your Home assistant from Scratch

This instruction will install Python 3.9 onto your System and allow you to us it as default.

This instruction is intended for a clean install of Home assistant best used with this instruction Installing Home Assistant

"DO NOT COPY AND PASTE STUFF IN QUOTES"

“LOG INTO THE TERMINAL.”

“GET LATEST UPDATES”

sudo apt update

sudo apt upgrade -y

“INSTALL THE DEPENDENCIES NEEDED TO BUILD”

sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev python3 python3-dev python3-venv python3-pip libffi-dev libtiff-dev autoconf libopenjp2-7 -y

“COMPILE (Takes Awhile) INSTALLS PYTHON INTO /usr/local/bin ”

version=3.9.1
wget -O /tmp/Python-$version.tar.xz https://www.python.org/ftp/python/$version/Python-$version.tar.xz

cd /tmp

tar xf Python-$version.tar.xz

cd Python-$version

./configure --enable-optimizations

sudo make altinstall

sudo apt -y autoremove

“CLEAN UP”

cd

sudo rm -rf /tmp/Python-$version

rm /tmp/Python-$version.tar.xz

“MAKE THIS VERSION DEFUALT, DO NOT DO THIS STEP AS IT BREAKS HOME ASSISTANT INSTALL




sudo ln -s /usr/local/bin/python3.9 /usr/bin/python3.9

echo "alias python=/usr/local/bin/python3.9" >> ~/.bashrc

echo "alias python3=/usr/local/bin/python3.9" >> ~/.bashrc

source ~/.bashrc

cd ..

. ~/.bashrc

“AND VERIFY: IF SHOWING 3.7 AND 2.7 HOME ASSISTANT SHOULD INSTALL

python3 -V

python2 -V

python -V

1 Like