1.安装python3.6
- [root@jumpserver2 ~]# yum -y install python36 python36-devel
上面安装缓慢,改为国内源,然后安装
- [root@jumpserver2 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
- --2020-10-31 09:07:32-- http://mirrors.aliyun.com/repo/epel-7.repo
- 正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 124.239.234.249, 27.128.221.241, 124.239.158.233, ...
- [root@jumpserver2 ~]#
- [root@jumpserver2 ~]# yum -y install python36 python36-devel
- 已加载插件:fastestmirror, langpacks
2.删除或备份原来指向python2的软链接
- [root@jumpserver bin]#mv /usr/bin/python /usr/bin/python.bak
- [root@jumpserver bin]# cd /usr/bin/
- [root@jumpserver bin]#rm -rf python
3.创建新的软链接
这时先查看一下安装python3所在的目录。
- [root@jumpserver bin]# pwd
- /usr/local/python/bin
- [root@jumpserver bin]# ls
- 2to3 2to3-3.6 easy_install-3.6 idle3 idle3.6 pip3 pip3.6 pydoc3 pydoc3.6 python3 python3.6 python3.6-config python3.6m python3.6m-config python3-config pyvenv pyvenv-3.6
- [root@jumpserver bin]#
- 然后做软链接:
- [root@jumpserver bin]# ln -s /usr/local/python/bin/python3 /usr/bin/python
4.查看是否更改成功
- [root@jumpserver /]# python -V
- Python 3.6.5
- [root@jumpserver /]#
- 或者
- [root@jumpserver /]# python
- Python 3.6.5 (default, Oct 30 2020, 10:52:02)
- [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
- Type "help", "copyright", "credits" or "license" for more information.
- >>>
- [root@jumpserver /]#
# 更改成功。
- 1:
- File "/usr/bin/yum", line 30
- except KeyboardInterrupt, e:
- ^
- SyntaxError: invalid syntax
- File "/usr/bin/yum", line 30
- except KeyboardInterrupt, e:
- ^
- 修改/usr/bin/yum第一行2.7
- 2:
- 升级 1 软件包 ( 25 依赖软件包)
- 总计:29 M
- 总下载量:27 M
- Downloading packages:
- No Presto metadata available for base
- File "/usr/libexec/urlgrabber-ext-down", line 28
- except OSError, e:
- ^
- SyntaxError: invalid syntax
- File "/usr/libexec/urlgrabber-ext-down", line 28
- except OSError, e:
- ^
- SyntaxError: invalid syntax
- File "/usr/libexec/urlgrabber-ext-down", line 28
- except OSError, e:
- ^
- SyntaxError: invalid syntax
- File "/usr/libexec/urlgrabber-ext-down", line 28
- except OSError, e:
- ^
- SyntaxError: invalid syntax
- File "/usr/libexec/urlgrabber-ext-down", line 28
- except OSError, e:
- ^
- SyntaxError: invalid syntax
- /usr/libexec/urlgrabber-ext-down第一行改成2.7
- #! /usr/bin/python2.7