centos 7 python3.7 安装

1. 查看原来版本的python2.7安装位置:

[root@hadoop2 Python-3.7.0]# whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/local/bin/python3.7m /usr/local/bin/python3.7 /usr/local/bin/python3.7m-config /usr/local/bin/python3.7-config /usr/local/lib/python3.7 /usr/include/python2.7 /usr/share/man/man1/python.1.gz
可以看到python在 /usr/bin/ 目录下

2. 安装python3.7 依赖包

[root@hadoop2 Python-3.7.0]#yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel  libffi-devel  gcc make 

[root@hadoop2 Python-3.7.0]# yum -y install epel-release
[root@hadoop2 Python-3.7.0]# yum install python-pip
 

2 。下载python3.7

[root@hadoop2 Python-3.7.0]# wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
 [root@hadoop2 Python-3.7.0]# xz -d Python-3.7.0.tar.xz 

[root@hadoop2 Python-3.7.0]# tar -xf Python-3.7.0.tar 

[root@hadoop2 Python-3.7.0]# cd Python-3.7.0/
[root@hadoop2 Python-3.7.0]# ./configure prefiex=/usr/local/python3
[root@hadoop2 Python-3.7.0]# make && make install

检测是否安装成功

[root@hadoop2 Python-3.7.0]# python3
Python 3.7.0 (default, Sep 27 2018, 19:05:02) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

3 。修改软连接

查看python3 安装位置

[root@hadoop2 Python-3.7.0]# whereis python3
python3: /usr/local/bin/python3.7m /usr/local/bin/python3.7 /usr/local/bin/python3.7m-config /usr/local/bin/python3 /usr/local/bin/python3.7-config /usr/local/lib/python3.7
[root@hadoop2 bin]# ln -s /usr/local/bin/python3.7 /usr/bin/python

检测是否安装成功

[root@hadoop2 bin]# python
Python 3.7.0 (default, Sep 27 2018, 19:05:02) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
4 。 修改执行文件

[root@hadoop2 bin]# vim /usr/bin/yum
[root@hadoop2 bin]# vim /usr/libexec/urlgrabber-ext-down
将#! /usr/bin/python修改为#! /usr/bin/python2

两个文件都修改

安装python3.7成功

参考:https://blog.csdn.net/lovefengruoqing/article/details/79284573

猜你喜欢

转载自blog.csdn.net/qq_33124081/article/details/82864238