Centos共存python3

文章目录

      • 1、Python版本下载
      • 2、解压
      • 3、安装
      • 4、安装成功

1、Python版本下载

所有版本下载地址

我下载的是3.6.5版本

服务器腾讯云Centos7.4

2、解压

[root@VMcentos ~]# pwd
/root
[root@VMcentos ~]# wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
[root@VMcentos ~]# ls
Python-3.6.5.tgz
[root@VMcentos ~]# tar -zxvf Python-3.6.5.tgz

3、安装

[root@VMcentos Python-3.6.5]# pwd
/root/Python-3.6.5
[root@VMcentos Python-3.6.5]# ls
aclocal.m4    configure.ac  install-sh  Makefile.pre.in  Parser    pyconfig.h.in  Tools
config.guess  Doc           Lib         Misc             PC        Python
config.sub    Grammar       LICENSE     Modules          PCbuild   README.rst
configure     Include       Mac         Objects          Programs  setup.py
[root@VMcentos Python-3.6.5]# ./configure 
[root@VMcentos Python-3.6.5]# sudo make
[root@VMcentos Python-3.6.5]# sudo make install

命令解释:

  • 设置安装路径: ./configure --prefix=/usr/python3(默认/usr/local/bin)
  • 编辑:make
  • 安装:make install
  • 创建软连接:ln -s 源路径 目标路径

4、安装成功

[root@VMcentos ~]# pwd
/root
[root@VMcentos ~]# python3 -V
Python 3.6.5
[root@VMcentos ~]# python -V
Python 2.7.5
[root@VMcentos bin]# pip -V
pip 9.0.3 from /usr/lib/python2.7/site-packages (python 2.7)
[root@VMcentos bin]# pip3 -V
pip 9.0.3 from /usr/local/lib/python3.6/site-packages (python 3.6)

5、错误

configure: error: in `/root/Python-3.6.5':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

缺少gcc编辑环境:yum install -y gcc

zipimport.ZipImportError: can’t decompress data

缺少依赖:yum -y install zlib*

你可能感兴趣的:(环境部署,Python3)