一、安装Python-2.7.12
1.安装Development Tools
1 wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
2 xz -d Python-2.7.8.tar.xz
3 tar -xvf Python-2.7.8.tar
4.安装Python-2.7.12
1) # Enter the directory:
2) cd Python-2.7.12
3)
4) # Run the configure:
5) ./configure --prefix=/usr/local
6)
7) # compile and install it:
8) make
9) make altinstall
10)
11) # Checking Python version:
12)
1.创建链接来使系统默认python变为python2.7
ln -fs /usr/local/python2.7/bin/python2.7 /usr/bin/python
2.查看Python版本
python –V
3.修改yum配置(否则yum无法正常运行)
vi /usr/bin/yum
将第一行的#!/usr/bin/python修改为系统原有的python版本地址#!/usr/bin/python2.6 二、安装Pip-8.1.2
1.安装setuptools(下载链接可从https://pypi.python.org/pypi/setuptools#code-of-conduct寻找)
1 #Download setuptools-25.1.6.tar.gz
2 wget --no-check-certificate https://pypi.python.org/packages/1f/7a/6b239a65d452b04ad8068193ae313b386e6fc745b92cd4584fccebecebf0/setuptools-25.1.6.tar.gz
3
4 # Extract the files:
5 tar -xvf setuptools-25.1.6.tar.gz
6 cd setuptools-25.1.6
7
8 # Install setuptools using the Python 2.7.12:
1.安装Development Tools
yum groupinstall -y 'development tools'
2安装SSL、bz2、zlib来为Python的安装做好准备工作yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget
3.下载Python-2.7.12.tar.xz并解压1 wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
2 xz -d Python-2.7.8.tar.xz
3 tar -xvf Python-2.7.8.tar
4.安装Python-2.7.12
1) # Enter the directory:
2) cd Python-2.7.12
3)
4) # Run the configure:
5) ./configure --prefix=/usr/local
6)
7) # compile and install it:
8) make
9) make altinstall
10)
11) # Checking Python version:
12)
1.创建链接来使系统默认python变为python2.7
ln -fs /usr/local/python2.7/bin/python2.7 /usr/bin/python
2.查看Python版本
python –V
3.修改yum配置(否则yum无法正常运行)
vi /usr/bin/yum
将第一行的#!/usr/bin/python修改为系统原有的python版本地址#!/usr/bin/python2.6 二、安装Pip-8.1.2
1.安装setuptools(下载链接可从https://pypi.python.org/pypi/setuptools#code-of-conduct寻找)
1 #Download setuptools-25.1.6.tar.gz
2 wget --no-check-certificate https://pypi.python.org/packages/1f/7a/6b239a65d452b04ad8068193ae313b386e6fc745b92cd4584fccebecebf0/setuptools-25.1.6.tar.gz
3
4 # Extract the files:
5 tar -xvf setuptools-25.1.6.tar.gz
6 cd setuptools-25.1.6
7
8 # Install setuptools using the Python 2.7.12:
9 python2.7 setup.py install
2.安装pip
#curl https://bootstrap.pypa.io/get-pip.py | python2.7 - 2种都可以
/usr/local/bin/easy_install pip
/usr/local/bin/pip -V