1、安装开发工具包

  sudo yum -y groupinstall "Development tools"


 

2、安装依赖包

  sudo 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 libffi-devel

 


 

3、下载python3.7的“源码”:

  wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz


 

4、解压

  tar -xJvf Python-3.7.0.tar.xz


 

5、用cd命令进入解压出来的文件夹

  cd Python-3.7.0


 

6、执行编译程序,并指定路径,最后共享

  ./configure --prefix=/usr/local/python3 --enable-shared


7、执行安装
  make && make install

 


 

8、配置环境变量(创建python3,pip,软链接,放入/usr/bin下)

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


 

9、将编译目录下的libpython3.7m.so.1.0文件复制到

  cp /root/Python3.7.0/libpython3.7m.so.1.0 /usr/lib64/libpython3.7m.so.1.0