Skip to content

Instantly share code, notes, and snippets.

@HarvsG
Last active November 14, 2020 22:55
Show Gist options
  • Save HarvsG/3504b03aee409aa2f059f4beaa8a5e7d to your computer and use it in GitHub Desktop.
Save HarvsG/3504b03aee409aa2f059f4beaa8a5e7d to your computer and use it in GitHub Desktop.
How to install a new version of python on the raspberry pi

Install the packages for compiling $ 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 wget

Set the python version you want $ version=3.8.5

Download $ wget https://www.python.org/ftp/python/$version/Python-$version.tgz ~/

Extract the file $ tar zxf ~/Python-$version.tgz

CD into the dir $ cd ~/Python-$version

Configure $ ./configure --enable-optimizations

Compile $ make -j4

Install $ sudo make altinstall

Clean up $ sudo apt-get remove 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

Remove remenants $ sudo rm -r ~/Python-$version.tgz ~/Python-$version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment