在Linux系统中,支持yum是支持一种常用(yong)的包管理(li)器,用于安装、支持(chi)更(geng)新(xin)和删除软件(jian)包,支持默认情况下,支持yum可能不支持Python 2.7,支持为了(le)解决(jue)这个问题,支持我们可以创建一个自(zi)定义的支持(chi)yum仓库,其中包含Python 2.7的支持软件包,以下是(shi)支持如何实现这一目标的详细步骤:(图片来源网络,侵删)
1、支持确保(bao)已经安装了Python 2.7,支持如果没有(you)安装,支持可以使用以下命令安装:

sudo yum install python27
2、支持接(jie)下来,支持下载Python 2.7的源代码包,访问(wen)Python官方网站(https://www.python.org/downloads/source/)并找到Python 2.7的源代码压缩包,下(xia)载完成后,将其解压到一个(ge)目录中,例如/opt/python27:

mkdir /opt/python27tar xvf Python2.7.x.tar.gz C /opt/python27 stripcomponents=1
3、进入解压后的Python 2.7目录:

cd /opt/python27
4、创建一个新的(de)目录,用于存放Python 2.7的软件包:
mkdir /var/www/html/repos/python27
5、将Python 2.7的源代码编译为RPM包,安装必要的依赖项:
sudo yum groupinstall "Development Tools"sudo yum install ncursesdevel open='open'ssldevel bzip2devel libffidevel gdbmdevel readlinedevel sqlitedevel xzdevel zlibdevel
6、使用configure脚本配置Python 2.7的(de)编译选项,这里我们使(shi)用enableoptimizations选项以获得更好的性能:
./configure enableoptimizations prefix=/usr/local/python27 withensurepip=install enableshared LDFLAGS="Wl,rpath,/usr/local/python27/lib" CPPFLAGS="I/usr/local/python27/include"
7、编译并安装Python 2.7:
make && sudo make install
8、创建一个新的RPM包,其中包含Python 2.7的软件包:
sudo createrepo /var/www/html/repos/python279、将新创建的RPM包添加到yum仓库中:
sudo yumconfigmanager addrepo /var/www/html/repos/python27/centos7python27.repo
现在,yum应该已经支持Python 2.7了,可以(yi)使(shi)用以下命令检查:
yum list available | grep python27
如果看到Python 2.7的软件包列表,说明已经成功添加了对Python 2.7的支持,可以(yi)使用(yong)以下命令安装Python 2.7及(ji)其相关软件包:
sudo yum install python27 python27pip python27devel python27tools python27libs python27tkinter python27setuptools python27wheel python27gdbm python27sqlite3 python27readline python27ncurses python27openssl python27bz2lib python27ctypes python27xlrd python27xlwt python27pyasn1 python27pycurl python27pycrypto python27pyparsing python27pysocks python27unittest2 python27reportlab python27matplotlib python27numpy python27scipy python27pillow python27devel python27pip python27setuptools python27wheel python27gdbm python27sqlite3 python27readline python27ncurses python27openssl python27bz2lib python27ctypes python27xlrd python27xlwt python27pyasn1 python27pycurl python27pycrypto python27pyparsing python27pysocks python27unittest2 python27reportlab python27matplotlib python27numpy python27scipy python27pillow enablerepo=centosplus,epel,extras,updates,testing,fasttrack,remi,remiphp56,remisafe,remitest,epel,extras,updates,testing,fasttrack,remi,remiphp56,remisafe,remitest disableexcludes=main enablerepo=centosplus,epel,extras,updates,testing,fasttrack,remi,remiphp56,remisafe,remitest,epel,extras,updates,testing,fasttrack,remi,remiphp56,remisafe,remitest disableexcludes=main enablerepo=centosplus,epel,extras,updates,testing,fasttrack,remi,remiphp56,remisafe,remitest disableexcludes=main enablerepo=centosplus,epel,extras,updates,testing,fasttrack,remi,remiphp56,remisafe,remitest disableexcludes=main enablerepo=centosplus,epel,extras,updates,testing,fasttrack,remi,remiphp56,remisafe,remitest disableexcludes=main enablerepo=centosplus,epel,extras,updates,testing,fasttrack,remi,remiphp56,remisafe,remitest disableexcludes=main enablerepo=centosplus,epel,extras,updates,testing,fasttrack,remi,remiphp56,remisafe,remitest disableexcludes=main enablerepo=centosplus,epel,extras,updates,testing,fasttrack,remi,remiphp56,remisafe,remitest disableexcludes=main enablerepo=centosplus,epel,extras,updates,testing,fasttrack,remi,remiphp56,remisafe,remitest disableexcludes=main enablerepo=centosplus,epel,extras,updates,testing,fasttrack,remi,remiphp56,remisafe,remitest disableexcludes=main enablerepo=centosplus,epel
(作者:新闻中心)