One-command Python source installer for Linux.π
This script downloads official CPython source code, installs build dependencies, compiles Python, installs it under /opt/python/<version> by default, and creates safe command links in /usr/local/bin.
Install the default Python version:
curl -fsSL https://raw.githubusercontent.com/sanmussh/install-python/main/install-python.sh | bashAfter installation, use:
python3.14
pip3.14curl -fsSL https://raw.githubusercontent.com/sanmussh/install-python/main/install-python.sh | bash -s -- --version 3.14.6By default, this script does not change python or pip.
If you want python and pip to point to the installed version, use:
curl -fsSL https://raw.githubusercontent.com/sanmussh/install-python/main/install-python.sh | bash -s -- --version 3.14.6 --set-defaultThis creates:
/usr/local/bin/python -> /opt/python/3.14.6/bin/python3.14
/usr/local/bin/pip -> /opt/python/3.14.6/bin/pip3.14
It does not delete or overwrite /usr/bin/python, /usr/bin/python3, or /usr/bin/pip.
If you first installed with the default behavior and later want python and pip to point to that existing installation, use:
curl -fsSL https://raw.githubusercontent.com/sanmussh/install-python/main/install-python.sh | bash -s -- --version 3.14.6 --set-default-onlyThis only creates command links. It does not download, build, or reinstall Python.
curl -fsSL https://raw.githubusercontent.com/sanmussh/install-python/main/install-python.sh | bash -s -- --version 3.14.6 --prefix /usr/local/pythonThe final install directory will be:
/usr/local/python/3.14.6
If you want to inspect the script first:
curl -fsSL https://raw.githubusercontent.com/sanmussh/install-python/main/install-python.sh -o install-python.sh
bash install-python.sh --version 3.14.6--version VERSION Python version to install. Default: 3.14.6
--prefix PATH Base install directory. Default: /opt/python
--set-default Also create python and pip commands in /usr/local/bin
--set-default-only Only make python and pip point to an existing installation
--skip-deps Skip dependency installation
--upgrade-pip Upgrade pip, setuptools, and wheel from PyPI after install
--keep-build-dir Keep the temporary build directory
-h, --help Show help
For Python 3.14.6, the real installation is:
/opt/python/3.14.6
The versioned command links are:
/usr/local/bin/python3.14
/usr/local/bin/pip3.14
If --set-default is used, these links are also created:
/usr/local/bin/python
/usr/local/bin/pip
The script supports common Linux distributions that use:
apt-get, such as Ubuntu and Debiandnf, such as Fedora, modern RHEL, CentOS Stream, AlmaLinux, and Rocky Linuxyum, such as older CentOS and RHEL systems
For Python 3.14.6, remove the install directory and command links:
sudo rm -rf /opt/python/3.14.6
sudo rm -f /usr/local/bin/python3.14 /usr/local/bin/pip3.14If you used --set-default, also remove:
sudo rm -f /usr/local/bin/python /usr/local/bin/pip