Linux离线安装Python3.6.8

一、环境

1,系统:CentOS 7

2,用户:root

3,Python版本:python3.6.8

二、安装

1,登录到centOS机器,新建文件夹
mkdir /usr/local/python3

2,将安装包和依赖包里的文件上传至/usr/local/python3

3,进入目录

cd /usr/local/python3/

4,安装依赖

#安装依赖包 zlib-devel

rpm -ivh zlib-devel-1.2.7-17.el7.x86_64.rpm

#安装依赖包 bzip2-devel

rpm -ivh bzip2-devel-1.0.6-13.el7.x86_64.rpm

#安装依赖包 epel-release

rpm -ivh epel-release-7-11.noarch.rpm

#安装依赖包 ncurses-devel

rpm -ivh ncurses-devel-5.9-13.20130511.el7.x86_64.rpm

# 安装依赖包 gcc(一定要按照以下的顺序进行安装)

rpm -ivh mpfr-3.1.1-4.el7.x86_64.rpm

rpm -ivh libmpc-1.0.1-3.el7.x86_64.rpm

rpm -ivh kernel-headers-3.10.0-514.el7.x86_64.rpm

rpm -ivh glibc-headers-2.17-157.el7.x86_64.rpm

rpm -ivh glibc-devel-2.17-157.el7.x86_64.rpm

rpm -ivh cpp-4.8.5-11.el7.x86_64.rpm

rpm -ivh gcc-4.8.5-11.el7.x86_64.rpm

# 安装依赖包 gcc-c+

rpm -ivh libstdc++-4.8.5-11.el7.x86_64.rpm

rpm -ivh libstdc++-devel-4.8.5-11.el7.x86_64.rpm

rpm -ivh gcc-c++-4.8.5-11.el7.x86_64.rpm

5,进行解压

tar -xzvf Python-3.6.8.tgz

6,进入解压路径

cd /usr/local/python3/Python-3.6.8

7,设置安装路径

./configure --prefix=/usr/local/python3.6 --enable-shared

make

make install

ln -s /usr/local/python3.6/bin/python3 /usr/bin/python3

echo "/usr/local/python3.6/lib" > /etc/ld.so.conf.d/python3.6.conf

ldconfig

8,检查Python3.6.8是否安装成功

python3 -V

显示如下图,说明成功;

 

9,删除安装包以及依赖包

rm -rf  /usr/local/python3

三、安装pip3

1,python 3.6.8中自带了pip,所以只需要建立链接就行

ln -s /usr/local/python3.6/bin/pip3.6 /usr/bin/pip3

2,检查pip是否安装成功

pip3 -V

出现如下图,表示正常:

 

posted @ 2021-05-25 16:45  整合侠  阅读(5449)  评论(4编辑  收藏  举报