centos7 安装Python3.8.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
yum install glibc-headers
yum install gcc-c++


下载并解压

wget https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tgz
tar -zxvf  Python-3.8.3.tgz

安装

mkdir /usr/local/python3 #创建编译安装目录
cd Python-3.8.3
./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 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软连接

rm -rf /usr/bin/python


配置软连接为python3

#添加python3的软链接

ln -s /usr/local/python3/bin/python3 /usr/bin/python


这个时候看下python默认版本

python -V


删除默认pip软连接,并添加pip3新的软连接

rm -rf /usr/bin/pip


#添加 pip3 的软链接

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip


更改yum配置
因为其要用到python2才能执行,否则会导致yum不能正常使用(不管安装 python3的那个版本,都必须要做的)


vi /usr/bin/yum
 #! /usr/bin/python 修改为 #! /usr/bin/python2
vi /usr/libexec/urlgrabber-ext-down
 #! /usr/bin/python 修改为 #! /usr/bin/python2
vi /usr/bin/yum-config-manager
#!/usr/bin/python 改为 #!/usr/bin/python2
没有这个文件的话运行下面的语句
yum -y install yum-utils
上一篇:.net 根据匿名类生成实体类,根据datatable生成实体类,根据sql生成实体类


下一篇:开启SAP CDS view DCL前后的读取性能对比