Installing Python 3.8 as default on Raspberry Pi

  •  
  •  
  •  
  •  
  •  
  •  

Raspberry pi defaults to Python 2.x, so if we want to use python 3.x it needs to be explicitly installed. Pretty simple, follow the steps below and we’ll install from source, build, and set the desired release as default.

Update

sudo apt-get update

Install Dependencies

sudo apt-get install -y 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 libffi-dev tar wget vim

Fetch latest Python 3.8.0

wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz

Untar & Build

sudo tar zxf Python-3.8.0.tgz
cd Python-3.8.0
sudo ./configure –enable-optimizations
sudo make -j 4
sudo make altinstall

Check Version

python3.8 -V

Create Alias to set Python 3.8.0 as default

echo “alias python=/usr/local/bin/python3.8” >> ~/.bashrc

Check alias version

python -V

This returns python 3.8, so we’re good to go !! If you want a different 3.x, just adjust the distro names accordingly. Enjoy !

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.