Linux centos7安装python3.8并且不影响python2

安装依赖

  • yum -y groupinstall "Development tools"
  • yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel libpcap-devel xz-devel libffi-devel

下载源码包, 编译安装

  • wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz
  • tar -xvJf Python-3.8.5.tar.xz
  • cd Python-3.8.5
  • ./configure -prefix=/usr/local/python3
  • make && make install

设置软连接

  • ln -s /usr/local/python3/bin/python3 /usr/bin/python3
  • ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
[root@console Python-3.8.5]# python3
Python 3.8.5 (default, Sep 21 2020, 11:16:18) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

你可能感兴趣的:(Linux centos7安装python3.8并且不影响python2)