python2.7.5升级到2.7.14或者直接升级到3.6.4

Posted 老虎逛大街

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python2.7.5升级到2.7.14或者直接升级到3.6.4相关的知识,希望对你有一定的参考价值。

python2.7.5升级到2.7.14

1.安装升级GCC

yum install -y gcc* openssl openssl-devel ncurses-devel.x86_64  bzip2-devel sqlite-devel  zlib python-devel mysql-devel openldap-devel

 

2.下载python安装包

wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tar.xz

 

3.解压

tar -xvf Python-2.7.14.tar.xz
 
4.编译安装
cd Python-2.7.14
./configure --prefix=/usr/local
make && make install
 
5.将老版本python更换
mv /usr/bin/python /usr/bin/python2.7.5
 
6.更换默认python
ln -s /usr/local/bin/python2.7  /usr/bin/python
 
7.#修改 yum以及urlgrabber-ext-down中的python
将#!/usr/bin/python改为 #!/usr/bin/python2.7.5
vim /usr/bin/yum
vim /usr/libexec/urlgrabber-ext-down
 

8.安装setuptools
wget --no-check-certificate https://pypi.python.org/packages/69/56/f0f52281b5175e3d9ca8623dadbc3b684e66350ea9e0006736194b265e99/setuptools-38.2.4.zip#md5=e8e05d4f8162c9341e1089c80f742f64
unzip setuptools-38.2.4.zip
cd setuptools-38.2.4
python setup.py install
cd ..

 

9.安装pip
wget --no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz
tar -xvf 1.5.5.tar.gz #解压文件
cd pip-1.5.5/
python setup.py install

 
 

python2.7.5升级到3.6.4

yum install -y gcc* openssl openssl-devel ncurses-devel.x86_64  bzip2-devel sqlite-devel  zlib python-devel mysql-devel openldap-devel

wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz

tar -xvf Python-3.6.4.tar.xz

cd Python-3.6.4

mkdir -p /usr/local/python3

./configure --prefix=/usr/local/python3

make && make install

mv /usr/bin/python /usr/bin/python2.7.5

mv /usr/bin/pip /usr/bin/pip2.7

ln -s /usr/local/python3/bin/python3 /usr/bin/python

ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip

 
 查看版本

[root@k8s-registry-91 Python-3.6.4]# pip -V
pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)
[root@k8s-registry-91 Python-3.6.4]# python -V
Python 3.6.4
[root@k8s-registry-91 Python-3.6.4]# which python
/usr/bin/python
[root@k8s-registry-91 Python-3.6.4]# which pip
/usr/bin/pip
[root@k8s-registry-91 Python-3.6.4]#

 

 

#修改 yum以及urlgrabber-ext-down中的python
vim /usr/bin/yum
vim /usr/libexec/urlgrabber-ext-down
将#!/usr/bin/python改为 #!/usr/bin/python2.7.5
 
 
PS:python3.6.4是默认安装pip的,所以不需要另行安装setuptools和pip.
 
 

以上是关于python2.7.5升级到2.7.14或者直接升级到3.6.4的主要内容,如果未能解决你的问题,请参考以下文章

python2.7.5升级到3.5.0

我的linux版本是centos6.4,由于想升级python2.7.5(自带)到python3.3,出现yum不用使用

Linux服务器上python2升为python3.6

python2.6.6升级python2.7.14

1-python 2.6 升级到 2.7

python2.7.5