Skip to content

Instantly share code, notes, and snippets.

@xslendix
Last active July 15, 2021 17:34
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save xslendix/fcb55ae06b49be557e3418cfa8af4534 to your computer and use it in GitHub Desktop.
Save xslendix/fcb55ae06b49be557e3418cfa8af4534 to your computer and use it in GitHub Desktop.
Install python 3.6 on your RPi!
#!/usr/bin/bash
putsc() {
echo -en "\e[34m :: \e[0m $@"
}
putscl() {
putsc "$@\n"
}
cores="$(ncores)"
putscl "Which Python version do you wish to download? (3.6.0, 3.6.4 etc.) "
read version
putscl Updating system.
sudo apt update
sudo apt upgrade
putscl Installing required build dependencies.
sudo apt 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 -y
putscl Downloading Python $version source code.
pushd
mkdir -p $HOME/.local/src
cd $HOME/.local/src
wget https://www.python.org/ftp/python/$version/Python-$version.tar.xz
tar xvf Python-$version.tar.xz
cd Python-$version
putscl Configuring.
./configure
putscl Compiling.
make -j$cores
putscl Installing.
sudo make altinstall
putsc "Installation done! Do you wish to delete the source code? [Y/n] "
read ans
if [[ ans == [Yy]* ]]
then
sudo rm -r Python-$version
rm Python-$version.tar.xz
sudo apt autoremove
sudo apt clean
fi
popd
putscl "Done! Python should now be installed in `/usr/local/bin/python$version`!"
@xslendix
Copy link
Author

xslendix commented Jul 15, 2021

Updated the script to make the output nicer and fixed some bugs.

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