centos下搭建python双版本环境

centos下搭建python双版本环境

centos7自带有python,版本是python2.7。但是在生产环境中,往往可能需要更高的python版本,甚至是有需要双版本python同时使用的情况。接下来我们手动安装python3,并且配置后可以并存使用。

一、安装python3

1、理清自带python位置


[root@centos~]# whereis pythonpython:/usr/bin/python2.7/usr/bin/python/usr/lib/python2.7/usr/lib64/python2.7/etc/python/usr/include/python2.7/usr/share/man/man1/python.1.gz

由此得知我们的python在 /usr/bin目录中


[root@centos~]# cd /usr/bin/[root@centosbin]# ll python*lrwxrwxrwx.1rootroot72月709:30python->python2lrwxrwxrwx.1rootroot92月709:30python2->python2.7-rwxr-xr-x.1rootroot71368月42017python2.7

可以看到,python指向的是python2,python2指向的是python2.7,因此我们可以装个python3,然后将python指向python3,然后python2指向python2.7,那么两个版本的python就能共存了。

2、更新用于下载编译python3的相关包


yuminstallzlib-develbzip2-developenssl-develncurses-develsqlite-develreadline-develtk-develgccmake

运行此命令即可更新

3、安装pip


yum-yinstallepel-releaseyuminstallpython-pip

运行以上两个命令安装pip

4、用pip安装wget


pipinstallwget

运行上述命令安装wget

5、用wget下载python3的源码包


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值