python centos7安装python3
2022/9/10 5:23:15
本文主要是介绍python centos7安装python3,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
目录- python centos7安装python3
- 安装前准备
- 安装依赖包
- 添加epel扩展源
- 安装pip
- 用pip装wget
- 下载python3
- 编译python3源码包,解压
- 编译
- 安装依赖zlib、zlib-deve
- 添加软链接,将原来的链接备份
- 添加软连接
- 验证
python centos7安装python3
centos7默认的python版本是2.7,现在想升级python3,同时保留python2.7
官网下载地址: https://www.python.org/ftp/python/
安装前准备
//执行 which python |xargs ls -l //可以看到指向了Python2 lrwxrwxrwx 1 root root 7 Sep 9 17:44 /usr/bin/python -> python2
安装依赖包
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
添加epel扩展源
yum -y install epel-release
安装pip
yum -y install python-pip
用pip装wget
pip install wget
下载python3
用wget下载python3的源码包,或者自己先下载好,上传到服务器再安装,如果网络快可以直接安装
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz
编译python3源码包,解压
xz -d Python-3.6.8.tar.xz tar -xf Python-3.6.8.tar
编译
进入解压后的目录,依次执行下面命令进行手动编译
cd Python-3.6.8 ./configure prefix=/usr/local/python3 make && make install
安装依赖zlib、zlib-deve
yum -y install zlib zlib-devel
添加软链接,将原来的链接备份
mv /usr/bin/python /usr/bin/python.bak
添加软连接
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python
验证
python -V
这篇关于python centos7安装python3的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-28Python编程基础教程
- 2024-12-27Python编程入门指南
- 2024-12-27Python编程基础
- 2024-12-27Python编程基础教程
- 2024-12-27Python编程基础指南
- 2024-12-24Python编程入门指南
- 2024-12-24Python编程基础入门
- 2024-12-24Python编程基础:变量与数据类型
- 2024-12-23使用python部署一个usdt合约,部署自己的usdt稳定币
- 2024-12-20Python编程入门指南