2019-07-09 CentOS7 安装python3

本文介绍了如何在CentOS7上手动安装Python3.8,因为默认的python版本是2.7,而yum安装的3.4版在安装某些软件包时可能遇到问题。首先,从指定链接下载Python3.8源码,然后进行编译安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在CentOS7上默认安装的是python2.7版本,而使用yum install python34安装的是3.4版本,这个版本在安装一些软件包如pip的时候会提示:

DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).

自然我们想安装高版本,需要手动安装。
1.下载python3
试用3.8使用下面链接

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

3.7.4使用下面链接

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

2.编译安装:

tar -zxvf Python-3.8.0b2.tgz
mkdir /usr/local/python3
#如果没有编译环境,会有错误提示,修复的办法是安装gcc或者工具套件
[root@ax Python-3.8.0b2]# ./configure --prefix=/usr/local/python3
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.8... no
checking for python3... no
checking for python... python
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "linux"
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/axing/Python-3.8.0b2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[root@ax Python-3.8.0b2]# yum -y groupinstall "Development Tools"
#装完后重新编译
cd Python-3.8.0b2
./configure --prefix=/usr/local/python3
make && make install
#设置软链接
[root@ax-3.8.0b2]# ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
[root@ax]# python3
Python 3.8.0b2 (default, Jul  8 2019, 12:01:59)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值