有网的机器

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 下载文件,根据自己的版本,更新下载链接
wget --no-check-certificate https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz

#安装yum-plugin-downloadonly软件包
yum install yum-plugin-downloadonly 

#创建依赖包缓存目录,用来保存依赖
mkdir -p /home/admin/python3 

#下载python3依赖安装包,downloaddir这个是保存依赖的路径
yum reinstall --downloadonly --downloaddir=/home/admin/python3 zlib-devel bzip2-devel openssl-devel ncurses-devel  epel-release gcc gcc-c++ xz-devel readline-devel gdbm-devel sqlite-devel tk-devel db4-devel libpcap-devel libffi-devel

脱网的机器

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 找到下载好的依赖目录
cd /home/admin/python3

# 执行安装依赖
rpm -Uvh ./*.rpm --nodeps --force

# 回到之前下载的安装包
cd /home/admin

# 解压安装包
tar -zxvf  Python-3.7.2.tar.xz

# 创建编译安装目录
mkdir /usr/local/python3 

# 进入python的解压目录
cd Python-3.7.0      
./configure --prefix=/usr/local/python3

# 编译安装
make && make install   

# 创建软连接
ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3

# 验证是否成功
python3 -V
pip3 -V

离线安装Flask

1
2
3
4
5
6
7
8
# 命令用于根据要求和依赖关系构建 Wheel 存档
pip wheel flask

# 下载flask的依赖save_path 是存储的目录
pip download flask -d save_path 

# 通过目录来安装软件
pip install --no-index --find-links=. flask