Sinisterly
Tutorial Installing Python 2.7.18 From The Source - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Python (https://sinister.li/Forum-Python)
+--- Thread: Tutorial Installing Python 2.7.18 From The Source (/Thread-Tutorial-Installing-Python-2-7-18-From-The-Source)



Installing Python 2.7.18 From The Source - DoXeD - 11-04-2024

First you import the script I use nano so you would do nano script.sh paste the script then ctrl + o and yes then chmod +x script.sh next you would type ./script.sh

here is the script this one is for debian 12 bookworm

Code:
#!/bin/bash # Script to fully automate the installation of Python 2.7.18 from source on Debian 12 # Exit immediately if a command exits with a non-zero status set -e # Variables PYTHON_VERSION="2.7.18" PYTHON_TAR="Python-${PYTHON_VERSION}.tgz" PYTHON_URL="https://www.python.org/ftp/python/${PYTHON_VERSION}/${PYTHON_TAR}" # Update package list and install dependencies echo "Updating package list and installing dependencies..." sudo apt-get update -y sudo apt-get install -y build-essential libssl-dev zlib1g-dev \ libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \ libffi-dev liblzma-dev # Download Python 2.7.18 if [ ! -f "${PYTHON_TAR}" ]; then echo "Downloading Python ${PYTHON_VERSION}..." wget ${PYTHON_URL} else echo "Python ${PYTHON_TAR} already downloaded." fi # Extract the downloaded tarball echo "Extracting ${PYTHON_TAR}..." tar -xzf ${PYTHON_TAR} # Change into the Python source directory cd "Python-${PYTHON_VERSION}" # Prepare for compilation echo "Configuring the build..." ./configure --enable-optimizations # Compile the source code echo "Compiling Python ${PYTHON_VERSION}..." make -j$(nproc) # Install Python echo "Installing Python ${PYTHON_VERSION}..." sudo make altinstall # Verify the installation echo "Verifying installation..." python2.7 --version echo "Python ${PYTHON_VERSION} installed successfully!"