Linux centos7安装python3并且不影响python2

时间:2021-05-30 12:38:43

一、安装依赖 

  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 (3.7以上需要libffi-devel)
 
二、获取安装包 编译安装
  wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
  tar -xvJf Python-3.6.4.tar.xz
  cd Python-3.6.4
  ./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