虚拟机中安装了Centos7操作系统,系统自带python 2.7
[root@bogon opt]# python
Python 2.7.5 (default, Apr 2 2020, 13:16:51)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
现需安装python3,采用源码安装 。
源码下载地址:Index of /ftp/python/3.8.0/Python-3.8.0.tgz
将下载文件上传到/opt目录下,进入/opt进行解压
cd /opt
tar -xvf Python-3.8.0.tgz
安装依赖
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
进入解压后文件夹,执行编译
./configure
make
make install
执行python命令查看是否安装成功
[root@bogon Python-3.8.0]# python3
Python 3.8.0 (default, Sep 30 2022, 19:00:39)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.