CentOS7平台安装Python3

CentOS7平台安装Python3

Python是一种解释型、面向对象、动态数据类型的高级程序设计语言。官方宣布,2020年1月1日,停止Python2的更新,CentOS7系统默认安装的是Python 2.7.5,Python3版本需要自行安装,为了不影响CentOS7部分命令的使用,我这里采取了Python2和Python3共存的方式…
1.安装Python3依赖包及开发环境

yum groupinstall -y "Development tools"
yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel zlib1g-dev zlib

2.下载安装包https://www.python.org/

wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz

3.解压安装包

tar -xvzf  Python-3.7.5.tgz

4.创建安装目录

mkdir /usr/local/python3

5.安装Python3

cd Python-3.7.5
./configure --prefix=/usr/local/python3 --enable-optimizations --with-ssl
make && make install

6.创建Python3和pip3软链接

ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3

7.验证Python3是否成功

python3 -V
# Python 3.7.5
pip3 -V
# pip 19.2.3 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)

你可能感兴趣的:(Python,python,centos,pip,服务器,开发工具)