[ root@localhost ~]# python --version
Python 2.6.6
[ root@localhost ~]# cat /etc/redhat-release
CentOS release 6.10(Final)
[ root@localhost ~]# yum groupinstall -y "Development tools"[root@localhost ~]# yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel
[ 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
## 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
[ root@localhost Python-2.7.13]# python --version
Python 2.7.13
## Return to Python 2.7.13 is normal
[ 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
[ 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
[ 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
[ 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