Centos6 install Python2.7.13

1、 View the Python version in the current system

[ root@localhost ~]# python --version
 Python 2.6.6

2、 Check CentOS version

[ root@localhost ~]# cat /etc/redhat-release
 CentOS release 6.10(Final)

3、 Install all development kits

[ root@localhost ~]# yum groupinstall -y "Development tools"[root@localhost ~]# yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel

4、 Download, compile and install Python 2.7.13

[ root@localhost ~]# wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
 [ root@localhost ~]# tar zxf Python-2.7.13.tgz
 [ root@localhost ~]# cd Python-2.7.13[root@localhost Python-2.7.13]# ./configure
 [ root@localhost Python-2.7.13]# make && make install
 ## Default Python 2.7.13 will be installed in/usr/local/bin directory
 [ root@localhost Python-2.7.13]# ll -tr /usr/local/bin/python*-rwxr-xr-x1root root 626156810 December 1217:17/usr/local/bin/python2.7-rwxr-xr-x1root root 168710 December 1217:17/usr/local/bin/python2.7-config
 lrwxrwxrwx 1root root 710 Dec 1217:17/usr/local/bin/python -> python2
 lrwxrwxrwx 1root root 910 Dec 1217:17/usr/local/bin/python2 -> python2.7
 lrwxrwxrwx 1root root 16 October 1217:17/usr/local/bin/python2-config -> python2.7-config
 lrwxrwxrwx 1root root 14 October 1217:17/usr/local/bin/python-config -> python2-config
 ## And the Python that comes with the system is in/usr/bin directory
 [ root@localhost Python-2.7.13]# ll -tr /usr/bin/python*-rwxr-xr-x.2root root 48648182016/usr/bin/python2.6-rwxr-xr-x.2root root 48648182016/usr/bin/python
 lrwxrwxrwx.1root root 61月252019/usr/bin/python2 -> python

5、 Update the system default Python version

 ## Rename the old version of Python by default
 [ root@localhost Python-2.7.13]# mv /usr/bin/python /usr/bin/python.old
 ## Then delete the system default python-config soft link
 [ root@localhost Python-2.7.13]# rm -f /usr/bin/python-config
 ## Finally create a new version of Python soft link
 [ root@localhost Python-2.7.13]# ln -s /usr/local/bin/python /usr/bin/python
 ## After the above steps are completed, the directory/usr/Python under bin should be
 [ root@localhost Python-2.7.13]# ll -tr /usr/bin/python*-rwxr-xr-x.2root root 48648182016/usr/bin/python.old
 - rwxr-xr-x.2root root 48648182016/usr/bin/python2.6
 lrwxrwxrwx.1root root 61月252019/usr/bin/python2 -> python
 lrwxrwxrwx 1root root 21 Oct 1217:20/usr/bin/python ->/usr/local/bin/python

6、 View the new Python version

[ root@localhost Python-2.7.13]# python --version
 Python 2.7.13
 ## Return to Python 2.7.13 is normal

7、 Install setuptools for the new version of Python

[ root@localhost Python-2.7.13]# wget https://bootstrap.pypa.io/ez_setup.py -O -| python
 ## After setuptools is installed correctly, easy_The install command will be installed in/usr/local/under the bin directory

8、 Install pip for the new version of Python

[ root@localhost Python-2.7.13]# easy_install pip
 ## After the correct installation is complete, the pip command will be installed in/usr/local/under the bin directory

9、 Modify the yum source to point to the original version

[ root@localhost Python-2.7.13]# vim /usr/bin/yum1#!/usr/bin/python2.6
 ## Modify the configuration file header#!/usr/bin/python to--->#!/usr/bin/python2.6

10、 Test

[ root@localhost Python-2.7.13]# pip install distribute
 DEPRECATION: Python 2.7 will reach the end of its life on January 1st,2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
 Collecting distribute
 Downloading https://files.pythonhosted.org/packages/5f/ad/1fde06877a8d7d5c9b60eff7de2d452f639916ae1d48f0b8f97bf97e570a/distribute-0.7.3.zip(145kB)|████████████████████████████████| 153kB 252kB/s 
 Requirement already satisfied: setuptools>=0.7in/usr/local/lib/python2.7/site-packages/setuptools-33.1.1-py2.7.egg(from distribute)(33.1.1)
 Installing collected packages: distribute
 Running setup.py install fordistribute ... done
 Successfully installed distribute-0.7.3

**Regarding operation and maintenance learning, sharing, and communication, the author has opened a WeChat public account [O&M Cat], interested friends can follow it, welcome to join, establish our own small circle, and learn operation and maintenance knowledge together. **

Friends who need technical exchanges can add me to WeChat and look forward to growing together with you. My WeChat:

Recommended Posts

Centos6 install Python2.7.13
Centos7 install Python 3.6.
CentOS install Python 3.6
Centos7 install Python2.7
Centos install Python3
CentOS6.8 install python2.7
CentOS + Python3.6+
1.5 Install Centos7
Centos 7.5 python3.6
centos7 install python3 and ipython
CentOS7 install python3 and pip3
CentOS 6.9 compile and install python
Centos6 install python3 pip3 ipython3
CentOS 6 compile and install python 3
Centos7.3 install nginx
CentOS7.2 install Mysql5.7.13
CentOS install Redmine
CentOS7 install MySQL
ubuntu18.04 install python2
Centos7 install protobuf
CentOS 7 install Docker
CentOS7 install GlusterFS
CentOS7 upgrade python3
CentOS 7.4 install Zabbix 3.4
CentOS7 install Docker
Centos6.5 install Tomcat
ubuntu12.04 install python3
Vmware install CentOS6
centos7 install docker-ce 18.01.0
CentOS 7.2 install MariaDB
CentOS 7 install Hadoop 3.0.0
Python - centos6 installation
Centos 7.6 install seleniu
CentOS 7.3 install Zabbix3
Centos7 install LAMP+PHPmyadmin
CentOS install mysql
CentOS install openjdk 1.8
CENTOS6.5 install CDH5.12.1 (1)
CentOS quickly install Python3 and pip3
How to install Python 3.8 on CentOS 8
CentOS install PHP
CentOS6 install mist.io
Centos7 install Docker
CentOS7 install mysql
How to install Python on CentOS 8
Install Python3 and ansible under CentOS8
centOs install rabbitMQ
CentOS 7 install MySQL 5.6
Centos7 install Nginx
CentOS6.5 install CDH5.13
Centos7 install docker18
centos7 install docker
CentOS install jdk
centos7 install nginx-rtmp
CentOS8 install MySQL8.0
Centos6.3 install KVM
CentOS install PostgreSQL 9.1
CentOS7 install mysql8
CentOS 7 install Java 1.8
CentOS8 install fastdfs6.06
CentOS 7 install Gitlab