Document

centos7 安装python3

cetnos7 默认安装python2,python3 需要手动安装

1 .官网下载python3 安装包

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

2 解压安装包

  1. xz -d Python-3.7.3.tar.xz
  2.  tar -xf Python-3.7.3.tar

3.进入解压目录,编译

  1. cd Python-3.7.3
  2.  ./configure prefix=/usr/local/python3 --with-ssl 或者./configure --prefix=/usr/local/python3 --enable-optimizations
  3.  make && make install或者
    make
    make altinstall

4 创建软链接

  1. ln -s /usr/local/python3/bin/python3 /usr/bin/python3
  2. ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

5.测试

python3 --version

 

 

 

编译中(第3步)遇到问题及解决方法

1 no acceptable C compiler found in $PATH

yum install -y gcc
2 zipimport.ZipImportError: can't decompress data

yum -y install zlib*
3 ModuleNotFoundError: No module named '_ctypes'

yum install libffi-devel -y

 

posted @ 2019-12-18 19:34  从未被超越  阅读(472)  评论(0编辑  收藏  举报