centos7 上安装Python3

安装python 3.7

//查看当前位置
[root@VM_0_13_centos ~]# pwd
/root
//产看自带的python版本
[root@VM_0_13_centos ~]# python --version
Python 2.7.5

//产看centos版本
[root@VM_0_13_centos ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

// 安装开发工具包
yum groupinstall -y "Development tools"

。。。
Complete!安装 完成 需要一些时间

// 安装其他工具包
yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel

正式安装

下载

//源地址可以登陆python官网,在下载出右键点击获取链接地址,获取。
 wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
 
 安装完成显示:
 - ‘Python-3.7.2.tar.xz.1’ saved [17042320/17042320]
另一个下载源
https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz

查看一下,下载的包

 ls
li                   Python-3.7.2.tar.xz.1  TESTfOLDER   test.txt
Python-3.7.2.tar.xz  testFile               testNewFile
// 不知道为什么出现了两个文件夹

解压:
使用

tar zxvf Python-3.7.2.tar.xz.1 //使用这条命令解压不成功,原因可能是最后一个不清楚是1还是字母l
tar (child): Python-3.7.2.tar.xz.l: 
 Cannot open: No such file or director
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
使用这个命令解压成功
tar -xvJf Python-3.7.2.tar.xz

查看解压后的文件:

 ls
li            Python-3.7.2.tar.xz    testFile    testNewFile
Python-3.7.2  Python-3.7.2.tar.xz.1  TESTfOLDER  test.txt

cd 到 Python-3.7.2
执行安装不成功 !!! 纳尼
重新下载
这次执行

wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz

ls
li Python-3.7.2.tgz testFile testNewFile test.txt
可以看到下载好了

解压

tar zxvf Python-3.7.2.tgz
//解压成功

ls
li Python-3.7.2 Python-3.7.2.tgz testFile testNewFile test.txt

 cd Python-3.7.2

ls
aclocal.m4 Grammar Makefile.pre.in Programs
CODE_OF_CONDUCT.rst Include Misc pyconfig.h.in
config.guess install-sh Modules Python
config.sub Lib Objects README.rst
configure LICENSE Parser setup.py
configure.ac m4 PC Tools
Doc Mac PCbuild
可以看到有很多文件

预编译

./configure

编译 & 安装

make && make install

查看

whereis python

python: /usr/bin/python2.7 /usr/bin/python /usr/lib/python2.7
/usr/lib64/python2 .7 /etc/python
/usr/local/bin/python3.7 /usr/local/bin/python3.7m-config /usr/lo
cal/bin/python3.7-config /usr/local/bin/python3.7m
/usr/local/lib/python3.7 /usr
/include/python2.7 /usr/share/man/man1/python.1.gz

测试python3

python3


[root@VM_0_13_centos ~]# python3
Python 3.7.2 (default, Jan 29 2019, 11:49:48)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("test python")
test python

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值