Bootstrap

CentOS6.10minimal安装Python3

CentOS6.0和6.10安装Python3.12.4没能成功 , 安装Python3.11.9也没能成

CentOS6.10minimal安装Python3.10.14


fp="/etc/yum.repos.d" ;    cp -a ${fp} ${fp}.$(date +%0y%0m%0d%0H%0M%0S).bkup
echo '[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.163.com/centos-vault/6.10/os/$basearch/
    http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
    http://mirrors.huaweicloud.com/centos-vault/6.10/os/$basearch/
    http://mirrors.cloud.tencent.com/centos-vault/6.10/os/$basearch/
    http://archive.kernel.org/centos-vault/6.10/os/$basearch/
    http://linuxsoft.cern.ch/centos-vault/6.10/os/$basearch/
    http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.ustc.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.cqupt.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.zju.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirror.nyist.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.pku.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirror.nsc.liu.se/centos-store/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.163.com/centos-vault/6.10/updates/$basearch/
    http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
    http://mirrors.huaweicloud.com/centos-vault/6.10/updates/$basearch/
    http://mirrors.cloud.tencent.com/centos-vault/6.10/updates/$basearch/
    http://archive.kernel.org/centos-vault/6.10/updates/$basearch/
    http://linuxsoft.cern.ch/centos-vault/6.10/updates/$basearch/
    http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.ustc.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.cqupt.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.zju.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirror.nyist.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.pku.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirror.nsc.liu.se/centos-store/6.10/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.163.com/centos-vault/6.10/extras/$basearch/
    http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
    http://mirrors.huaweicloud.com/centos-vault/6.10/extras/$basearch/
    http://mirrors.cloud.tencent.com/centos-vault/6.10/extras/$basearch/
    http://archive.kernel.org/centos-vault/6.10/extras/$basearch/
    http://linuxsoft.cern.ch/centos-vault/6.10/extras/$basearch/
    http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.ustc.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.cqupt.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.zju.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirror.nyist.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.pku.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirror.nsc.liu.se/centos-store/6.10/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[epel-archive]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://mirrors.aliyun.com/epel-archive/6/$basearch
    http://mirrors.cloud.tencent.com/epel-archive/6/$basearch
    http://repo.jing.rocks/fedora-buffet/archive/epel/6/$basearch
    http://archives.fedoraproject.org/pub/archive/epel/6/$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

' > /etc/yum.repos.d/CentOS-Base.repo
yum clean all ; yum makecache
yum -y install gcc gcc-c++ autoconf automake make zlib zlib-devel
FolderPathTempVar="/tmp/InstallTempFolder/Python3" ; rm -rf ${FolderPathTempVar} ; mkdir -p ${FolderPathTempVar}/CompressPackage ; cd $_ ;
curl -O https://www.python.org/ftp/python/3.10.14/Python-3.10.14.tgz
mkdir ../UncompressFolder  ; tar -axf * -C ../UncompressFolder ; cd ../UncompressFolder/*
./configure && make && make install


CentOS6.10minimal安装Python3.10.12


fp="/etc/yum.repos.d" ;    cp -a ${fp} ${fp}.$(date +%0y%0m%0d%0H%0M%0S).bkup
echo '[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.163.com/centos-vault/6.10/os/$basearch/
    http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
    http://mirrors.huaweicloud.com/centos-vault/6.10/os/$basearch/
    http://mirrors.cloud.tencent.com/centos-vault/6.10/os/$basearch/
    http://archive.kernel.org/centos-vault/6.10/os/$basearch/
    http://linuxsoft.cern.ch/centos-vault/6.10/os/$basearch/
    http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.ustc.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.cqupt.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.zju.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirror.nyist.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.pku.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirror.nsc.liu.se/centos-store/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.163.com/centos-vault/6.10/updates/$basearch/
    http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
    http://mirrors.huaweicloud.com/centos-vault/6.10/updates/$basearch/
    http://mirrors.cloud.tencent.com/centos-vault/6.10/updates/$basearch/
    http://archive.kernel.org/centos-vault/6.10/updates/$basearch/
    http://linuxsoft.cern.ch/centos-vault/6.10/updates/$basearch/
    http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.ustc.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.cqupt.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.zju.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirror.nyist.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.pku.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirror.nsc.liu.se/centos-store/6.10/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.163.com/centos-vault/6.10/extras/$basearch/
    http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
    http://mirrors.huaweicloud.com/centos-vault/6.10/extras/$basearch/
    http://mirrors.cloud.tencent.com/centos-vault/6.10/extras/$basearch/
    http://archive.kernel.org/centos-vault/6.10/extras/$basearch/
    http://linuxsoft.cern.ch/centos-vault/6.10/extras/$basearch/
    http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.ustc.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.cqupt.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.zju.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirror.nyist.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.pku.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirror.nsc.liu.se/centos-store/6.10/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[epel-archive]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://mirrors.aliyun.com/epel-archive/6/$basearch
    http://mirrors.cloud.tencent.com/epel-archive/6/$basearch
    http://repo.jing.rocks/fedora-buffet/archive/epel/6/$basearch
    http://archives.fedoraproject.org/pub/archive/epel/6/$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

' > /etc/yum.repos.d/CentOS-Base.repo
yum clean all ; yum makecache
yum -y install gcc gcc-c++ autoconf automake make zlib zlib-devel
FolderPathTempVar="/tmp/InstallTempFolder/Python3" ; rm -rf ${FolderPathTempVar} ; mkdir -p ${FolderPathTempVar}/CompressPackage ; cd $_ ;
curl -O https://www.python.org/ftp/python/3.10.12/Python-3.10.12.tgz
mkdir ../UncompressFolder  ; tar -axf * -C ../UncompressFolder ; cd ../UncompressFolder/*
./configure && make && make install


CentOS6.10minimal安装Python3.9.19


fp="/etc/yum.repos.d" ;    cp -a ${fp} ${fp}.$(date +%0y%0m%0d%0H%0M%0S).bkup
echo '[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.163.com/centos-vault/6.10/os/$basearch/
    http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
    http://mirrors.huaweicloud.com/centos-vault/6.10/os/$basearch/
    http://mirrors.cloud.tencent.com/centos-vault/6.10/os/$basearch/
    http://archive.kernel.org/centos-vault/6.10/os/$basearch/
    http://linuxsoft.cern.ch/centos-vault/6.10/os/$basearch/
    http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.ustc.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.cqupt.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.zju.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirror.nyist.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.pku.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirror.nsc.liu.se/centos-store/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.163.com/centos-vault/6.10/updates/$basearch/
    http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
    http://mirrors.huaweicloud.com/centos-vault/6.10/updates/$basearch/
    http://mirrors.cloud.tencent.com/centos-vault/6.10/updates/$basearch/
    http://archive.kernel.org/centos-vault/6.10/updates/$basearch/
    http://linuxsoft.cern.ch/centos-vault/6.10/updates/$basearch/
    http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.ustc.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.cqupt.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.zju.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirror.nyist.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.pku.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirror.nsc.liu.se/centos-store/6.10/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.163.com/centos-vault/6.10/extras/$basearch/
    http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
    http://mirrors.huaweicloud.com/centos-vault/6.10/extras/$basearch/
    http://mirrors.cloud.tencent.com/centos-vault/6.10/extras/$basearch/
    http://archive.kernel.org/centos-vault/6.10/extras/$basearch/
    http://linuxsoft.cern.ch/centos-vault/6.10/extras/$basearch/
    http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.ustc.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.cqupt.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.zju.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirror.nyist.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.pku.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirror.nsc.liu.se/centos-store/6.10/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[epel-archive]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://mirrors.aliyun.com/epel-archive/6/$basearch
    http://mirrors.cloud.tencent.com/epel-archive/6/$basearch
    http://repo.jing.rocks/fedora-buffet/archive/epel/6/$basearch
    http://archives.fedoraproject.org/pub/archive/epel/6/$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

' > /etc/yum.repos.d/CentOS-Base.repo
yum clean all ; yum makecache
yum -y install gcc gcc-c++ autoconf automake make zlib zlib-devel
FolderPathTempVar="/tmp/InstallTempFolder/Python3" ; rm -rf ${FolderPathTempVar} ; mkdir -p ${FolderPathTempVar}/CompressPackage ; cd $_ ;
curl -O https://www.python.org/ftp/python/3.9.19/Python-3.9.19.tgz
mkdir ../UncompressFolder  ; tar -axf * -C ../UncompressFolder ; cd ../UncompressFolder/*
./configure && make && make install



CentOS6.10minimal安装Python3.8.19


fp="/etc/yum.repos.d" ;    cp -a ${fp} ${fp}.$(date +%0y%0m%0d%0H%0M%0S).bkup
echo '[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.163.com/centos-vault/6.10/os/$basearch/
    http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
    http://mirrors.huaweicloud.com/centos-vault/6.10/os/$basearch/
    http://mirrors.cloud.tencent.com/centos-vault/6.10/os/$basearch/
    http://archive.kernel.org/centos-vault/6.10/os/$basearch/
    http://linuxsoft.cern.ch/centos-vault/6.10/os/$basearch/
    http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.ustc.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.cqupt.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.zju.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirror.nyist.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirrors.pku.edu.cn/centos-vault/6.10/os/$basearch/
    http://mirror.nsc.liu.se/centos-store/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.163.com/centos-vault/6.10/updates/$basearch/
    http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
    http://mirrors.huaweicloud.com/centos-vault/6.10/updates/$basearch/
    http://mirrors.cloud.tencent.com/centos-vault/6.10/updates/$basearch/
    http://archive.kernel.org/centos-vault/6.10/updates/$basearch/
    http://linuxsoft.cern.ch/centos-vault/6.10/updates/$basearch/
    http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.ustc.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.cqupt.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.zju.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirror.nyist.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirrors.pku.edu.cn/centos-vault/6.10/updates/$basearch/
    http://mirror.nsc.liu.se/centos-store/6.10/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.163.com/centos-vault/6.10/extras/$basearch/
    http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
    http://mirrors.huaweicloud.com/centos-vault/6.10/extras/$basearch/
    http://mirrors.cloud.tencent.com/centos-vault/6.10/extras/$basearch/
    http://archive.kernel.org/centos-vault/6.10/extras/$basearch/
    http://linuxsoft.cern.ch/centos-vault/6.10/extras/$basearch/
    http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.ustc.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.cqupt.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.zju.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirror.nyist.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirrors.pku.edu.cn/centos-vault/6.10/extras/$basearch/
    http://mirror.nsc.liu.se/centos-store/6.10/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[epel-archive]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://mirrors.aliyun.com/epel-archive/6/$basearch
    http://mirrors.cloud.tencent.com/epel-archive/6/$basearch
    http://repo.jing.rocks/fedora-buffet/archive/epel/6/$basearch
    http://archives.fedoraproject.org/pub/archive/epel/6/$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

' > /etc/yum.repos.d/CentOS-Base.repo
yum clean all ; yum makecache
yum -y install gcc gcc-c++ autoconf automake make zlib zlib-devel
FolderPathTempVar="/tmp/InstallTempFolder/Python3" ; rm -rf ${FolderPathTempVar} ; mkdir -p ${FolderPathTempVar}/CompressPackage ; cd $_ ;
curl -O https://www.python.org/ftp/python/3.8.19/Python-3.8.19.tgz
mkdir ../UncompressFolder  ; tar -axf * -C ../UncompressFolder ; cd ../UncompressFolder/*
./configure && make && make install





CentOS6安装Python3

在CentOS 6上安装Python 3涉及一系列步骤,由于CentOS 6的官方仓库可能不包含最新版本的Python 3,因此通常需要采用其他方法,如从源代码编译安装或使用第三方仓库。以下是在CentOS 6上安装Python 3的详细步骤:

一、准备工作

  1. 更新系统:首先,确保你的CentOS 6系统是最新的。可以通过运行yum update命令来更新所有已安装的包。

  2. 安装必要的工具:安装编译Python 3所需的开发工具。这些工具包括gcc、make等。可以通过运行yum groupinstall "Development Tools"命令来安装。

二、从源代码编译安装

  1. 下载Python 3源码

    • 访问Python官方网站(https://www.python.org/downloads/)或使用wget命令从命令行下载Python 3的源码包。例如,可以使用类似wget https://www.python.org/ftp/python/3.x.x/Python-3.x.x.tgz的命令下载最新版本(将3.x.x替换为具体的版本号,如3.9.5)。
  2. 解压源码包

    • 使用tar -xzvf Python-3.x.x.tgz命令解压下载的源码包。
  3. 编译安装

    • 进入解压后的目录,使用cd Python-3.x.x命令。
    • 配置安装选项,使用./configure --prefix=/usr/local/python3命令(这里的/usr/local/python3是安装路径,可以根据需要修改)。
    • 编译并安装Python 3,使用make && make install命令。

三、配置环境变量

  1. 修改默认的Python链接(可选,但通常不推荐,因为这可能会影响系统工具如yum):

    • 考虑到yum等系统工具依赖于Python 2.x,通常不建议直接修改/usr/bin/python的链接。相反,你可以通过创建指向新Python版本的软链接来避免冲突。例如,可以使用ln -s /usr/local/python3/bin/python3 /usr/bin/python3命令创建python3的软链接。
  2. 更新PATH环境变量

    • 将Python 3的安装路径添加到你的PATH环境变量中,以便在终端中可以直接使用python3命令。这可以通过修改用户的shell配置文件(如.bashrc.bash_profile)来实现,添加类似export PATH=/usr/local/python3/bin:$PATH的行。

四、验证安装

  • 使用python3 --version命令来验证Python 3是否已成功安装并配置。

五、使用第三方仓库(可选)

如果你不想从源代码编译Python 3,也可以考虑使用第三方仓库,如EPEL(Extra Packages for Enterprise Linux)或SCL(Software Collections)。这些仓库提供了预编译的软件包,可以简化安装过程。但请注意,这些仓库中的软件包可能不是最新版本,且可能需要额外的配置才能使用。

注意事项

  • 在安装Python 3之前,请确保备份重要数据,以防万一出现问题。
  • 由于CentOS 6已经过时,不再接收官方更新和支持,因此建议在新版本的操作系统上安装Python 3以获得更好的性能和安全性。
  • 如果你的系统上有多个Python版本,请确保在编写脚本或运行命令时指定正确的Python版本。
;