Centos共存python3

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*

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值