Data4Strategy

——合抱之木,生于毫末;九层之台,起于累土

【原创】Centos 7 升级安装python3.7.4

1、安装必须的软件

#更新源中包列表

yum -y update

#先安装扩展源EPEL 才能安装pip 否则会报错

yum -y install epel-release

//解决ssl问题,否则报错:pip is configured with locations that require TLS/SSL

//你只需执行即可,具体解决过程参见:http://www.cnblogs.com/minglee/p/9232673.html

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel

yum -y install gcc gcc-c++ kernel-devel

2、解压python

tar -zxf Python-3.7.4.tgz

3、安装python

cd /usr/local/

mkdir python3

chmod 777 python3/

#配置安装路径

cd /softwares/Python-3.7.4/

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

make all

make install

#主要看是否有pip3 和 python3

ll /usr/local/python3/bin

4、软连接替换

#备份旧版本

mv /usr/bin/python /usr/bin/python2.7

#做软连接替换

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

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip -f

5、调整yum配置和软件安装配置文件

修改yum文件,因为升级了版本以后,yum就会报错

vi /usr/bin/yum

#!/usr/bin/python 修改为 #!/usr/bin/python2.7

在安装软件的时候又会报错误

vi /usr/libexec/urlgrabber-ext-down

#!/usr/bin/python 修改为#!/usr/bin/python2.7

6、更改源

mkdir ~/.pip

cd ~/.pip && touch pip.conf

vi pip.conf

[global]

index-url = http://pypi.douban.com/simple

[install]

use-mirrors =true

mirrors =http://pypi.douban.com/simple/

trusted-host =pypi.douban.com

7、pip升级

pip install --upgrade pip


如果您觉得此文章对您有帮助,请点击右下方【推荐】让更多人看到,thanks!

posted @ 2019-11-11 15:42  John.Xiong  阅读(3957)  评论(0编辑  收藏  举报