1. 安装支持包
yum -y groupinstall "Development tools" 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
2. 下载源代码
wget https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tar.xz
3. 安装
mkdir -p /usr/local/python3 mv Python-3.6.7.tar.xz /usr/local/python3/ cd /usr/local/python3 tar -xvJf Python-3.6.2.tar.xz cd Python-3.6.7 ./configure --prefix=/usr/local/python3 make && make install
4. 创建软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
5. 测试
python3
6. 注意
centos7原本就安装了Python2,而且这个Python2不能被删除,因为有很多系统命令,比如yum都要用到。
不要把Python3的安装目录覆盖Python2
:) enjoy
原文地址:https://www.cnblogs.com/want990/p/11532605.html
时间: 2024-10-07 12:28:01