Problem scenario
You want a script to install Python 3.x that will work on any type of Linux. What should you do?
Solution
Prerequisite
Install make. If you need assistance, see this posting.
Install the zlib development tools. If you have a Red Hat derivative (e.g., CentOS or Fedora), you this command: sudo yum -y install zlib-devel
If you have a Debian/Ubuntu system, use this: sudo apt -y install zlib1g-dev
If you have a SUSE server, run this: sudo zypper -n install zlib-devel
Procedures
Run this script (e.g., sudo bash installer.sh):
echo "This will fail if the zlib development tools have not been installed"
sleep 3
curl -k https://www.python.org/ftp/python/3.9.0/Python-3.9.0a1.tar.xz > Python-3.9.0a1.tar.xz
mv Python-3.9.0a1.tar.xz /usr/bin/
cd /usr/bin/
tar xf Python-3.9.0a1.tar.xz
cd Python-3.9.0a1
./configure --prefix=/usr/local
make && sudo make altinstall
# You must use "altinstall" in the command above. If you use "make install", you will have two versions of Python installed.
ln -s /usr/bin/Python-3.9.0a1/python /usr/bin/python