CentOS 7 中默认安装了 Python,版本比较低(2.7.5)
1、查看python版本
[[email protected] bin]# python --version
2、首先安装依赖包
[[email protected] bin]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
3 、下载python3安装包
[[email protected] bin]# cd /usr/local/src
[[email protected] bin]# wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
4、解压
[[email protected] src]# tar xvzf Python-3.7.4.tgz
5、创建文件夹把python3安装在里面
[[email protected] src]# mkdir -p /usr/local/python3
6、编译安装
[[email protected] src]# cd Python-3.7.4
[[email protected] src]#./configure --prefix=/usr/local/python3/
[[email protected] src]# make && make install
7、建立软连接
[[email protected] src]# ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
[[email protected] src]# ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
8、验证和测试
[[email protected] bin]#python3
原文地址:https://blog.51cto.com/14388114/2481305
时间: 2024-11-06 07:36:23