📦 Install Required Dependencies
Install the necessary packages before proceeding with the Python installation:
sudo yum groupinstall -y "Development tools"
sudo yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel \
sqlite-devel readline-devel tk-devel gdbm-devel db4-devel \
libpcap-devel xz-devel libffi-devel
🔽 Download and Extract Python
Download and extract Python using the following commands:
wget https://www.python.org/ftp/python/3.12.3/Python-3.12.3.tgz
tar -zxvf Python-3.12.3.tgz
cd Python-3.12.3
🛠Configure, Compile, and Install
Configure the Python installation and compile it:
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
make && sudo make install
🔗 Create Symbolic Links
Create symbolic links for Python and pip:
sudo ln -sf /usr/local/python3/bin/python3 /usr/bin/python3
sudo ln -sf /usr/local/python3/bin/pip3 /usr/bin/pip3
sudo ln -sf /usr/local/python3/bin/pip3 /usr/bin/pip
✅ Confirm the Python and Pip Versions
Verify that the correct versions of Python and pip are being used:
python --version
python3 --version
pip --version
Install a Python package to ensure pip is working correctly:
pip install tqdm
🎉 Congratulations! You have successfully installed Python 3.12.2 on your CentOS 7.9 system.