Last active
March 18, 2022 21:48
-
-
Save a904guy/b210f940cc8cfc86399f1731e9b7aa39 to your computer and use it in GitHub Desktop.
Installs Python PPA. Versions: 2.3, 2.4, 2.5, 2.6, 2.7, 3.2, 3.3, 3.4, 3.5, 3.5, 3.6. Installs Python, PIP, setuptools, virtualenv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Possible to pass version as first arg of the script | |
# `install_python 3.6` | |
versions="2.3 2.4 2.5 2.6, 2.7 3.2 3.3 3.4 3.5 3.5 3.6" | |
## Parse first arg or else ask which version to install | |
if [ $1 ]; | |
then | |
echo "Selected Python Version: $1" | |
version=$1 | |
else | |
echo -n "Which version do you want to install? Options: ($versions): " | |
read version | |
fi | |
## Validate version is acceptable | |
if [[ $versions != *"$version"* ]]; | |
then | |
echo "Please select one of the following versions: $versions" | |
exit 1 | |
fi | |
## Install ppa, update, then install base python version packages | |
sudo apt-get install software-properties-common -y | |
sudo add-apt-repository ppa:fkrull/deadsnakes -y | |
sudo apt-get update | |
sudo apt-get install wget python$version python$version-dev -y -m | |
## Install Latest PIP | |
curl https://bootstrap.pypa.io/get-pip.py | sudo -H python$version | |
## Install setuptools and virtualenv | |
sudo -H python$version -m pip install setuptools virtualenv | |
## Check if installed globally or give prompt to. | |
folder="$(dirname $0)"; | |
if [ "$folder" != "/usr/local/bin" ]; | |
then | |
echo "Install or upgrade install_python to global path to run anywhere? [y/n]: " | |
read install | |
if [ "${install,,}" = "y" ]; | |
then | |
sudo rm -f /usr/local/bin/install_python; | |
sudo wget install_python.src.sh -o /usr/local/bin/; | |
sudo chmod a+x /usr/local/bin/install_python.sh; | |
echo "Installed. You can run as 'install_python' now from anywhere." | |
fi | |
fi | |
echo "All Done, Enjoy" | |
# Author: Andy Hawkins | |
# Company: Hawkins.Tech | |
# Email: YW5keUBoYXdraW5zLnRlY2g= | |
# Discord: https://discord.gg/ggbtaA8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Easy install:
bash <(curl -L https://gist.github.com/a904guy/b210f940cc8cfc86399f1731e9b7aa39/raw/562917a38b0b083af7d6624000730af8afbc500a/install_python.sh)