The CentOS6.x system has always been using Python2.6.x (currently the latest version is python-2.6.6), which sometimes cannot meet the needs of certain application production and development environments. It is installed directly from the official Yum warehouse and epel. Python2.7 (currently the latest version is python-2.7.12) seems to be impossible unless a more third-party software source is used. There are many system components in CentOS 6.x system that use Python 2.6, such as yum mentioned just now, but yum is not necessarily the only program that depends on Python 2.6, although the general production environment will not use particularly mixed operations Environment, but you need to pay attention to whether certain tools & programs can run normally under Python2.7 during use.
Installing Python2.7.x is actually very simple. The only thing you need to understand is that you must use the --enable-shared (enable building shared python library) option to install the python dynamic link library (share object, /usr/lib64/libpython2.7.so.1.0), this file will be used by many python modules (even python itself). When this option is not used, you can add this option to recompile Python, see the steps Below.
Download link: https://www.python.org/downloads/
wget -c https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz
wget -c https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz.asc
wget https://www.python.org/static/files/pubkeys.txt
gpg --import pubkeys.txt
gpg --recv-keys 6A45C816 36580288 7D9DC8D2 18ADD4FF A4135B38 A74B06BF EA5BBD71 ED9D77D5 E6DF025C AA65421D 6F5E1540 F73C700D 487034E5
gpg --verify Python-2.7.12.tgz.asc # Good signature
tar zxf Python-2.7.12.tgz
cd Python-2.7.12/
yum install -y gcc gcc-c++ openssl-devel
. /configure --enable-shared
make && make install
echo '/usr/local/lib'>/etc/ld.so.conf.d/libpython2.7.conf
ldconfig
python --version
sed -i '1 s/python/python2.6/g'/usr/bin/yum
wget https://bootstrap.pypa.io/ez_setup.py
python ez_setup.py # setuptools
easy_install --version
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py # pip
pip --version
tag: CentOS Python2.7, centos install python2.7, compile and install python2.7
Recommended Posts