在CentOS7上默认安装的是python2.7版本,而使用yum install python34安装的是3.4版本,这个版本在安装一些软件包如pip的时候会提示:
DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).
自然我们想安装高版本,需要手动安装。
1.下载python3
试用3.8使用下面链接
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0b2.tgz
3.7.4使用下面链接
wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4rc2.tgz
2.编译安装:
tar -zxvf Python-3.8.0b2.tgz
mkdir /usr/local/python3
#如果没有编译环境,会有错误提示,修复的办法是安装gcc或者工具套件
[root@ax Python-3.8.0b2]# ./configure --prefix=/usr/local/python3
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.8... no
checking for python3... no
checking for python... python
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "linux"
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/axing/Python-3.8.0b2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[root@ax Python-3.8.0b2]# yum -y groupinstall "Development Tools"
#装完后重新编译
cd Python-3.8.0b2
./configure --prefix=/usr/local/python3
make && make install
#设置软链接
[root@ax-3.8.0b2]# ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
[root@ax]# python3
Python 3.8.0b2 (default, Jul 8 2019, 12:01:59)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>