Centos 7 x86_64 环境Python2.7升级Python3.7.4

升级Python3.7.4

#安装补丁包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc libffi-devel #下载文件
wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
#解压
tar zxf Python-3.7.4.tgz
#编译

cd Python-3.7.4 ./configure --prefix=/usr/local/python3.7 #安装 make && make install #添加环境变量 PATH=$PATH:$HOME/bin:/usr/local/python3.7/bin #更新python默认指向为python3.7 mv /usr/bin/python /usr/bin/python.bak ln -s /usr/local/bin/python3.7/ usr/bin/python

安装pip

#安装pip
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

常见问题:

1.3.7版本需要两个新的包libffi-devel和zlib-deve,安装此包之后再次进行编译安装即可。

yum install libffi-devel -y
yum -y install zlib zlib-deve

 2.yum失败

[root@elegant-codes-3 home]# yum
  File "/usr/bin/yum", line 30
    except KeyboardInterrupt, e

处理方法:版本修改为2.7

vi /usr/libexec/urlgrabber-ext-down
vi /usr/bin/yum-config-manager
vi /usr/bin/yum

3.pip命令-bash: pip: command not found

处理方法:新增PATH

vi ~/.bashrc
#末尾新增
PATH=$PATH:$HOME/bin:/usr/local/python3.7/bin
source ~/.bashrc

 

 



 








posted @ 2020-02-19 12:07  aongao  阅读(190)  评论(0编辑  收藏  举报