杰瑞科技汇

Python 2.7.11 RPM包哪里下载?

Of course. Here is a comprehensive guide to finding, installing, and managing Python 2.7.11 RPM packages, primarily for Red Hat-based Linux distributions like CentOS, RHEL, and Fedora.

Python 2.7.11 RPM包哪里下载?-图1
(图片来源网络,侵删)

Executive Summary

Finding a pre-built python-2.7.11 RPM package for modern systems is extremely difficult because Python 2.7 reached its official end-of-life in January 2025. Most repositories have removed these old versions.

Your best options are:

  1. Use a Software Collection (SCL): This is the recommended and safest method. It provides an isolated, modern Python 2.7 environment without conflicting with your system's packages.
  2. Build from Source: If you absolutely need the specific 7.11 version and an SCL isn't available, you can compile it from source and create your own RPM.
  3. Find an Old Archive: As a last resort, you can try to find the RPM in old software archives, but this is not recommended for security reasons.

Option 1: Using a Software Collection (Recommended)

This is the modern, supported way to get a specific Python version on a Red Hat-based system. It provides a python27 command that runs an isolated version of Python, leaving your system's Python untouched.

Install the centos-release-scl Repository: This repository contains the Software Collections packages.

Python 2.7.11 RPM包哪里下载?-图2
(图片来源网络,侵删)
# For CentOS 7
sudo yum install centos-release-scl
# For RHEL 7, you may need to enable the optional channel
sudo yum install centos-release-scl-rh

Install the Python 2.7 Collection: The collection is typically named python27.

sudo yum install python27

This will install Python 2.7 (often a more recent patch like 2.7.18, which is more secure than 2.7.11) and its tools.

Activate and Use the Collection: You can activate the collection for your current shell session.

# Activate for the current terminal session
scl enable python27 bash
# Verify the version
python --version
# You should see something like Python 2.7.18...

(Optional) Make it Permanent for a User: To add the python27 collection to your user's login shell environment, edit your shell configuration file (e.g., ~/.bashrc or ~/.bash_profile).

Python 2.7.11 RPM包哪里下载?-图3
(图片来源网络,侵删)
echo 'source /opt/rh/python27/enable' >> ~/.bashrc
source ~/.bashrc

Using Development Tools: The collection also includes pip and virtualenv.

scl enable python27 'pip install --user some-package'
# or, if you made it permanent:
pip install --user some-package

Option 2: Building from Source

If you absolutely must have version 7.11 specifically, you can download the source code and build it into an RPM package yourself. This gives you full control.

Install Required Build Tools:

sudo yum groupinstall "Development Tools"
sudo yum install rpm-build redhat-rpm-config openssl-devel zlib-devel bzip2-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

Download Python 2.7.11 Source:

wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
tar -xvzf Python-2.7.11.tgz
cd Python-2.7.11

Create an RPM Spec File: You need a .spec file to tell rpmbuild how to create the package. You can often find one online or create a basic one.

A simple python27.spec file would look like this (place it in ~/rpmbuild/SPECS/):

Name:           python27
Version:        2.7.11
Release:        1%{?dist}
Summary:        An interpreted, interactive, object-oriented programming language
License:        Python
URL:            https://www.python.org/
Source0:        https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description
Python is a programming language that lets you work more quickly and integrate your systems more effectively.
%prep
%setup -q
%build
./configure --enable-shared --with-threads --enable-unicode=ucs4 --prefix=/usr
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
/usr/bin/python2.7
/usr/lib/python2.7
/usr/include/python2.7
/usr/lib/libpython2.7.so
/usr/lib/libpython2.7.so.1.0

Organize Your rpmbuild Directory: rpmbuild expects files in specific locations.

mkdir -p ~/rpmbuild/{SOURCES,SPECS,SRPMS,RPMS,BUILD}
# Move the source tarball to SOURCES
mv ../Python-2.7.11.tgz ~/rpmbuild/SOURCES/
# Move the spec file to SPECS
mv ../python27.spec ~/rpmbuild/SPECS/

Build the RPM: Run the build command from your home directory.

rpmbuild -ba rpmbuild/SPECS/python27.spec

Find Your New RPM: The compiled RPM packages will be in ~/rpmbuild/RPMS/x86_64/ (or i686 for 32-bit).

ls ~/rpmbuild/RPMS/x86_64/
# You should see files like:
# python27-2.7.11-1.el7.x86_64.rpm
# python27-devel-2.7.11-1.el7.x86_64.rpm
# python27-libs-2.7.11-1.el7.x86_64.rpm

Install the RPM:

sudo yum install ~/rpmbuild/RPMS/x86_64/python27-2.7.11-1.el7.x86_64.rpm

Option 3: Finding an Archive (Not Recommended)

You can try to find a pre-built RPM from old repositories or archives like the Fedora Archive.

Example Search Path: https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/23/Everything/x86_64/os/Packages/p/

Why this is a bad idea:

  • Security Vulnerabilities: Python 2.7.11 is ancient and contains numerous known security flaws that will never be patched.
  • Dependency Hell: The RPM will have old dependencies that may conflict with your modern system.
  • No Support: You are on your own if something goes wrong.

Important Considerations for Python 2.7

  1. End-of-Life (EOL): Python 2.7 is no longer maintained. The only updates since 2025 have been security patches to a select few organizations. You should not use it for any new development.
  2. Migrate to Python 3: The long-term solution is to migrate your applications to Python 3. Most modern libraries and frameworks have dropped support for Python 2.
  3. Virtual Environments: Even if you install Python 2.7, always use a virtual environment (virtualenv or venv) to manage project dependencies and avoid polluting your global Python installation.
分享:
扫描分享到社交APP
上一篇
下一篇