Centos7安装Python
- CentOS7默认安装的是Python 2.7.5
一.安装依赖环境
yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel
二.下载Python3.9安装包
- 如果没有wget命令,先行安装wegt
- yum install wegt
在opt目录下输入
wget http://npm.taobao.org/mirrors/python/3.9.0/Python-3.9.0.tgz
三.解压安装包
tar -zxvf Python-3.9.0.tgz
(1)创建目录: mkdir -p /usr/local/python3.9
(2)解压安装包: tar -zxvf Python-3.9.0.tgz
(3)进入Python-3.9.0文件夹中配置安装位置
四.安装编译器(gcc)和libffi-devel
输入make如何出入make install
注意输入make和make install 一定要在Python-3.9.0文件夹下
检查python3.9的编译器:/usr/local/python3.9/bin/python3
五.建立软连接
[root@centos-moxc python3.9]# ln -s /usr/local/python3.9/bin/python3/usr/bin/python3
[root@centos-moxc python3.9]# ln -s /usr/local/python3.9/bin/pip3 /usr/bin/pip3
检查Python3及pip3是否可以使用: