前言
Linux 默认自带的是 python2 的版本, python2 的版本目前已经不演进, 且存在诸多漏洞, 现在大部分 python 项目都要求是 python3.
版本信息
- [[email protected] bin]# cat /proc/version
- Linux version 3.10.0-862.11.6.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Tue Aug
安装过程
- # 安装依赖
- yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel SQLite-devel readline-devel tk-devel gcc make libffi-devel
- # 获取大包
- wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
- tar xvf Python-3.7.5.tgz
- cd Python-3.7.5
- # 编译
- ./configure --prefix=/usr/local/python3
- make
- make install
- # 建立软链接
- ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
- ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
- # 验证
- [[email protected] bin]# python3
- Python 3.7.5 (default, Jan 23 2020, 10:28:05)
- [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on Linux
- Type "help", "copyright", "credits" or "license" for more information.
- >>>
来源: http://www.bubuko.com/infodetail-3392970.html