第一章 Centos7下Python3.9.4编译安装

一、安装依赖

#1.安装相关依赖
[root@prd-airflow001 ~]$ yum -y install zlib zlib-devel
[root@prd-airflow001 ~]$ yum -y install bzip2 bzip2-devel
[root@prd-airflow001 ~]$ yum -y install ncurses ncurses-devel
[root@prd-airflow001 ~]$ yum -y install readline readline-devel
[root@prd-airflow001 ~]$ yum -y install openssl openssl-devel
[root@prd-airflow001 ~]$ yum -y install openssl-static
[root@prd-airflow001 ~]$ yum -y install xz lzma xz-devel
[root@prd-airflow001 ~]$ yum -y install sqlite sqlite-devel
[root@prd-airflow001 ~]$ yum -y install gdbm gdbm-devel
[root@prd-airflow001 ~]$ yum -y install tk tk-devel
[root@prd-airflow001 ~]$ yum -y install  db4-devel libpcap-devel libffi-devel 
[root@prd-airflow001 ~]$ yum -y install epel-release
[root@prd-airflow001 ~]$ yum -y install gcc

二、下载安装包

#1.使用wget下载Python源码压缩包到/root目录下
[root@prd-airflow001 ~]$ cd /data/software
[root@prd-airflow001 /data/software]$ wget https://www.python.org/ftp/python/3.9.4/Python-3.9.4.tgz

#2.解压python3安装包
[root@prd-airflow001 /data/software]$ tar -zxvf Python-3.9.4.tgz -C /root

#3.进入安装目录
[root@prd-airflow001 /data/software]$ cd /root/Python-3.9.4/

#4.创建python3程序目录
[root@prd-airflow001 ~/Python-3.9.4]$ mkdir /usr/local/python3.9.4

三、生成Makefile文件

[root@prd-airflow001 ~/Python-3.9.4]$ mkdir bld
[root@prd-airflow001 ~/Python-3.9.4]$ cd bld/
[root@prd-airflow001 ~/Python-3.9.4/bld]$ ../configure --prefix=/usr/local/python3.9.4

四、编译安装

#1.编译安装
[root@prd-airflow001 ~/Python-3.9.4/bld]$ make && make install

#2.做软连接
[root@prd-airflow001 ~/Python-3.9.4/bld]$ cd /usr/local/
[root@prd-airflow001 /usr/local]$ ln -s python3.9.4 python3

五、配置环境变量

[root@prd-airflow001 ~/Python-3.9.4/bld]$ vim /etc/profile.d/python3.sh
export PATH=/usr/local/python3/bin:$PATH
                                                                    
[root@prd-airflow001 ~/Python-3.9.4/bld]$ source  /etc/profile

六、查看python版本

#1.查看Python版本
[root@prd-airflow001 ~/Python-3.9.4/bld]$ python3 -V
Python 3.9.4

#2.检测pip是否可用
[root@prd-airflow001 ~/Python-3.9.4/bld]$ pip3 -V
pip 20.2.3 from /usr/local/python3/lib/python3.9/site-packages/pip (python 3.9)

#3.升级pip
[root@prd-airflow001 ~/Python-3.9.4/bld]$ pip3 install --upgrade pip

#4.再次查看pip版本
[root@prd-airflow001 ~/Python-3.9.4/bld]$ pip3 -V
pip 21.1.2 from /usr/local/python3/lib/python3.9/site-packages/pip (python 3.9)
posted @ 2021-06-23 14:59  年少纵马且长歌  阅读(196)  评论(0编辑  收藏  举报