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
1.官网下载所需 python3 的版本 wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz 2.解压 tar -xf Python-3.6.1.tgz 3.进入目录 cd Python-3.6.1/
./configure --prefix=/usr/local/python3 make make install
1.移除旧版本 mv /usr/bin/python /usr/bin/python_bak 2.创建新版本 ln -s /usr/local/python3/bin/python3 /usr/bin/python
python -V
系统默认版本切换成 py3 后会发生两个问题啦~ yum 和 pip3 无法使用,下面是解决方法
报错: [root@Topaz tools]# yum -y install xxx File "/usr/bin/yum", line 30 解决: // shangbang指向py2.7 [root@Topaz tools]# vim /usr/bin/yum #!/usr/bin/python2.7 // CentOS 7 /usr/libexec/urlgrabber-ext-down 也需要改 [root@Topaz tools]# vim /usr/libexec/urlgrabber-ext-down #!/usr/bin/python2.7
加软链指向 /usr/local/bin/
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
Always keep learning.