如何在centos 7安装python3.5

1、下载python

我们以源码的方式进行安装,进入/usr/local/src/,用wget下载源码:
[root@VM_109_202_centos /]# cd /usr/local/src/
[root@VM_109_202_centos src]# wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tar.xz

2、解压缩

我们用tar命令把下载的包解压缩,以下省略解压所产生的信息,如下:
[root@VM_109_202_centos src]# ls -l
total 14484
-rw-r--r-- 1 root root 14808460 Sep 13  2015 Python-3.5.0.tar.xz
[root@VM_109_202_centos src]# tar xvJf Python-3.5.0.tar.xz
...
...
[root@VM_109_202_centos src]# ls -l
total 14488
drwxrwxr-x 16 oldwang oldwang     4096 Sep 13  2015 Python-3.5.0
-rw-r--r--  1 root    root    14808460 Sep 13  2015 Python-3.5.0.tar.xz

3、编译和安装

进入Python-3.5.0文件夹,注: –prefix用于指定要安装的目录:
[root@VM_109_202_centos src]# cd Python-3.5.0/
[root@VM_109_202_centos Python-3.5.0]# ./configure --prefix=/usr/local/python-3.5
[root@VM_109_202_centos Python-3.5.0]# make
[root@VM_109_202_centos Python-3.5.0]# make install

4、检查python的版本

进入/usr/local/python-3.5/, 输入python,我的提示信息是这样的:
[root@VM_109_202_centos python-3.5]# python
Python 2.7.5 (default, Sep 15 2016, 22:37:39) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
这可能跟系统的环境变量设置有关,输入exit(),退出python。进入/usr/bin/目录,看到有很多个python文件:
>>> exit()
[root@VM_109_202_centos python-3.5]# cd /usr/bin
[root@VM_109_202_centos bin]# ls -l python*
lrwxrwxrwx 1 root root    7 Dec  5 13:05 python -> python2
lrwxrwxrwx 1 root root    9 Dec  5 13:05 python2 -> python2.7
-rwxr-xr-x 1 root root 7136 Sep 16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值