Skip to content

Instantly share code, notes, and snippets.

@dameyerdave
Last active June 4, 2024 06:01
Show Gist options
  • Save dameyerdave/db2e2e97a92d3911017fc4378c8f2bf7 to your computer and use it in GitHub Desktop.
Save dameyerdave/db2e2e97a92d3911017fc4378c8f2bf7 to your computer and use it in GitHub Desktop.
Install Python 3.10 on RHEL/CENTOS
#!/usr/bin/env bash
sudo dnf install wget yum-utils make gcc openssl-devel bzip2-devel libffi-devel zlib-devel
# Ubuntu: sudo apt install -y wget yum-utils make gcc libssl-dev libbz2-dev libffi-dev zlib1g-dev
mkdir tmp
cd tmp
wget https://www.python.org/ftp/python/3.10.8/Python-3.10.8.tgz
tar xzf Python-3.10.8.tgz
cd Python-3.10.8
sudo ./configure --with-system-ffi --with-computed-gotos --enable-loadable-sqlite-extensions --enable-optimizations
sudo make -j $(nproc)
# to remove the unused stuff: find . -maxdepth 1 -mtime +1 -exec rm -rf {} \;
# to install pip we can use: python -m ensurepip --upgrade
# it will install pip into $HOME/.local/bin
sudo make altinstall
sudo rm Python-3.10.8.tgz
sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10 1
sudo update-alternatives --set python3 /usr/local/bin/python3.10
sudo rm -rf /usr/local/bin/pip3
sudo update-alternatives --install /usr/bin/pip3 pip3 /usr/local/bin/pip3.10 1
sudo update-alternatives --set pip3 /usr/local/bin/pip3.10
@jandson-oliveira
Copy link

sudo update-alternatives --install /usr/bin/pip3 pip3 /usr/local/bin/pip3.10 1
failed to link /usr/bin/pip3 -> /etc/alternatives/pip3: /usr/bin/pip3 exists and it is not a symlink
(kubespray-venv) [root@tuxmail-labtech Python-3.10.8]# sudo ln -s /usr/local/bin/pip3.10 /usr/bin/pip3
ln: falha ao criar link simbólico '/usr/bin/pip3': Arquivo existe
(kubespray-venv) [root@tuxmail-labtech Python-3.10.8]# sudo rm /usr/bin/pip3
(kubespray-venv) [root@tuxmail-labtech Python-3.10.8]# sudo ln -s /usr/local/bin/pip3.10 /usr/bin/pip3
(kubespray-venv) [root@tuxmail-labtech Python-3.10.8]# sudo update-alternatives --install /usr/bin/pip3 pip3 /usr/local/bin/pip3.10 1

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