1.yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
1.[root@centos-0 lcr]# yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
2.已加载插件:fastestmirror, langpacks
3.base | 3.6 kB 00:00:00
4.extras | 3.4 kB 00:00:00
5.updates | 3.4 kB 00:00:00
6.Loading mirror speeds from cached hostfile
7. * base: mirrors.btte.net
8. * extras: ftp.sjtu.edu.cn
9. * updates: mirrors.btte.net
10.软件包 1:openssl-devel-1.0.1e-60.el7_3.1.x86_64 已安装并且是最新版本
11.软件包 bzip2-devel-1.0.6-13.el7.x86_64 已安装并且是最新版本
12.软件包 expat-devel-2.1.0-10.el7_3.x86_64 已安装并且是最新版本
13.软件包 gdbm-devel-1.10-8.el7.x86_64 已安装并且是最新版本
14.软件包 readline-devel-6.2-9.el7.x86_64 已安装并且是最新版本
15.软件包 sqlite-devel-3.7.17-8.el7.x86_64 已安装并且是最新版本
16.无须任何处理
1、python官网下载https://www.python.org
1.wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
1.[root@centos-0 lcr]# wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
2.--2017-09-09 23:39:29-- https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
3.正在解析主机 www.python.org (www.python.org)... 151.101.72.223, 2a04:4e42:11::223
4.正在连接 www.python.org (www.python.org)|151.101.72.223|:443... 已连接。
5.已发出 HTTP 请求,正在等待回应... 200 OK
6.长度:22256403 (21M) [application/octet-stream]
7.正在保存至: “Python-3.6.0.tgz”
8.
9.100%[============================================>] 22,256,403 423KB/s 用时 1m 48s
10.
11.2017-09-09 23:41:18 (201 KB/s) - 已保存 “Python-3.6.0.tgz” [22256403/22256403])
12.
2、解压缩
1.tar -xzvf Python-3.6.0.tgz -C /tmp
3、进入解压目录
1.cd /tmp/Python-3.6.0/
4、把Python3.6安装到 /usr/local 目录
1../configure --prefix=/usr/local
1.If you want a release build with all optimizations active (LTO, PGO, etc),please run ./configure --enable-optimizations
2.
5、编译安装
1.make
2.make altinstall
1.# Substitution happens here, as the completely-expanded BINDIR
2.# is not available in configure
3.sed -e "s,@EXENAME@,/usr/local/bin/python3.6m," < ./Misc/python-config.in >python-config.py
4.# Replace makefile compat. variable references with shell script compat. ones; ->
5.LC_ALL=C sed -e 's,\$(\([A-Za-z0-9_]*\)),\$\{\1\},g' < Misc/python-config.sh >python-config
6.# On Darwin, always use the python version of the script, the shell
7.# version doesn't use the compiler customizations that are provided
8.# in python (_osx_support.py).
9.if test `uname -s` = Darwin; then \
10. cp python-config.py python-config; \
11.fi
1.rm /usr/local/lib/python3.6/lib-dynload/_sysconfigdata_m_linux_x86_64-linux-gnu.py
2.rm -r /usr/local/lib/python3.6/lib-dynload/__pycache__
3./usr/bin/install -c -m 644 ./Misc/python.man \
4. /usr/local/share/man/man1/python3.6.1
5.if test "xupgrade" != "xno" ; then \
6. case upgrade in \
7. upgrade) ensurepip="--altinstall --upgrade" ;; \
8. install|*) ensurepip="--altinstall" ;; \
9. esac; \
10. ./python -E -m ensurepip \
11. $ensurepip --root=/ ; \
12.fi
13.Collecting setuptools
14.Collecting pip
15.Installing collected packages: setuptools, pip
16.Successfully installed pip-9.0.1 setuptools-28.8.0
- python3.6程序的执行文件:/usr/local/bin/python3.6
- python3.6应用程序目录:/usr/local/lib/python3.6
- pip3的执行文件:/usr/local/bin/pip3.6
- pyenv3的执行文件:/usr/local/bin/pyenv-3.6
1.cd /usr/bin
2.mv python python.backup
3.#备份旧的python
4.ln -s /usr/local/bin/python3.6 /usr/bin/python
5.ln -s /usr/local/bin/python3.6 /usr/bin/python3
1.[root@centos-0 Python-3.6.0]# cd /usr/bin/
2.[root@centos-0 bin]# ls python*
3.python2 python2.7 python2.7-config python2-config python.backup python-config
4.[root@centos-0 bin]# mv python python.backup
5.[root@centos-0 bin]# ln -s /usr/local/bin/python3.6 /usr/bin/python
6.[root@centos-0 bin]# ln -s /usr/local/bin/python3.6 /usr/bin/python3
7.[root@centos-0 bin]#
8.
1.# cd /usr/bin
2.# ls yum*
1.yum yum-config-manager yum-debug-restore yum-groups-manager
2.yum-builddep yum-debug-dump yumdownloader
更改以上文件头为
#!/usr/bin/python
改为#!/usr/bin/python2
1.[root@centos-0 bin]# ls yum*
2.yum yum-config-manager yum-debug-restore yum-groups-manager
3.yum-builddep yum-debug-dump yumdownloader
1. vi /usr/bin/gnome-tweak-tool
#!/usr/bin/python
改为#!/usr/bin/python2
1.vi /usr/libexec/urlgrabber-ext-down
#!/usr/bin/python
改为#!/usr/bin/python2
1.[root@centos-0 bin]# python -V
2.Python 3.6.0
3.[root@centos-0 bin]# python
4.Python 3.6.0 (default, Sep 9 2017, 23:54:25)
5.[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
6.Type "help", "copyright", "credits" or "license" for more information.
7.>>>
至此,centos 升级Python3完毕
点击回到fatcat的主页