Centos7安装Python3.8
Centos7安装Python3.8
安装编译相关工具
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 -y install libffi-devel
下载python安装包
wget https://www.python.org/ftp/python/3.8.7/Python-3.8.7.tar.xz
tar -xvf Python-3.8.7.tar.xz
编译安装python
mkdir /usr/local/python3 #创建编译安装目录
cd Python-3.8.7./configure --prefix=/usr/local/python3
make && make install
安装过,出现下面两行就成功了
Installing collected packages: setuptools, pip
Successfully installed pip-19.2.3 setuptools-41.2.0```
创建软连接
# 查看当前python软连接ll /usr/bin/ |grep python
lrwxrwxrwx 1 root root 7 Jul 23 2020 python -> python2
lrwxrwxrwx 1 root root 9 Jul 23 2020 python2 -> python2.7
-rwxr-xr-x 1 root root 7144 Apr 2 2020 python2.7
默认系统安装的是python2.7,留着不动
配置软连接python3
#添加python3的软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
这个时候看下python默认版本
python -V>>>>>Python 2.7.5
python3 -V>>>>>Python 3.8.7
删除默认pip软连接,并添加pip3新的软连接
ll /usr/bin/ |grep pip
#添加 pip3 的软链接
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
# 验证
pip -V>>>>>pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
pip3 -V>>>>>pip 20.2.3 from /usr/local/python3/lib/python3.8/site-packages/pip (python 3.8)
标签:bin,python,devel,Centos7,Python3.8,pip,安装,python3,usr
From: https://www.cnblogs.com/guowenrui/p/17617994.html