系统自带的python为2版本,很多支持受限,安装python3版本
[root@simsrv1 ~]# python
Python 2.7.5 (default, Mar 20 2020, 17:08:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
安装依赖包
[root@simsrv1 ~]# yum -y install gcc gcc-c++ zlib-devel openssl-devel readline-devel libffi-devel sqlite-devel tcl-devel tk-devel
源码安装python3网盘地址
安装包链接:
链接:https://pan.baidu.com/s/1v6zHoF-biGZoB5IboOaPLQ
提取码:mw3s
此处一定要注意,python默认安装在/usr/bin下面,为了不影响系统python2的运行,我们需要手动指定python的安装目录到别处,不然会影响系统里面大量python2编写的软件运行
[root@simsrv1 freetools]# which python
/usr/bin/python[root@simsrv1 freetools]# file /usr/bin/yum
/usr/bin/yum: Python script, ASCII text executable
源码安装:
[root@simsrv1 freetools]# tar -xf Python-3.6.7.tgz
[root@simsrv1 freetools]# cd Python-3.6.7/
[root@simsrv1 Python-3.6.7]# ./configure --prefix=/usr/local[root@simsrv1 Python-3.6.7]# make && make install
默认情况下,python不支持按tab键补全
[root@simsrv1 test]# cat /usr/local/bin/tab-wenwu.py
from rlcompleter import readlinereadline.parse_and_bind('tab: complete')
[root@simsrv1 ~]# cat ~/.bashrc
# .bashrc# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fiexport PYTHONSTARTUP=/usr/local/bin/tab-wenwu.py
[root@simsrv1 ~]# source .bashrc