转载自
安装编译相关工具
1 2 3
| 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 yum install libffi-devel -y
|
下载 python 安装包
1 2
| wget https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tgz tar -zxvf Python-3.8.3.tgz
|
编译安装 python
1 2 3 4
| mkdir /usr/local/python3 cd Python-3.8.3 ./configure --prefix=/usr/local/python3 make && make install
|
安装过,出现下面两行就成功了
1 2
| Installing collected packages: setuptools, pip Successfully installed pip-19.2.3 setuptools-41.2.0
|
创建软连接
1 2
| ll /usr/bin/ |grep python
|
1 2 3
| lrwxrwxrwx 1 root root 7 Nov 26 2018 python -> python2 lrwxrwxrwx 1 root root 9 Nov 26 2018 python2 -> python2.7 -rwxr-xr-x 1 root root 7216 Jul 13 2018 python2.7
|
默认系统安装的是 python2.7
删除 python 软连接
配置软连接为 python3
1 2
| ln -s /usr/local/python3/bin/python3 /usr/bin/python
|
这个时候看下 python 默认版本
删除默认 pip 软连接,并添加 pip3 新的软连接
1 2 3
| rm -rf /usr/bin/pip
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
|
更改 yum 配置
因为其要用到 python2 才能执行,否则会导致 yum 不能正常使用(不管安装 python3 的那个版本,都必须要做的)
1 2 3 4 5 6
| vi /usr/bin/yum 把 vi /usr/libexec/urlgrabber-ext-down 把 vi /usr/bin/yum-config-manager
|