离线编译安装Python-3.6.9.tgz
安装Python3
1、首先需要确定CentOS上是否包含支持安装其他软件包的开发工具(Development Tools),没有此包,将无法安装
2、将下载好的Python3包放到centos上,解压Python包并进入
3、运行configuration script,安装Python,命令如下:
tar -zxvf Python-3.6.9.tgz
cd Python-3.6.9
./configure
make
make install
4、查看Python3安装位置
whereis python3
5、安装完成报错,缺少zlib包,往下看
RuntimeError: Compression requires the (missing) zlib module
安装zlib
wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make check
make install
zlib安装成功后,重新进入Python3安装目录执行:
make clean
make
make install
注:执行完后pip和setuptools也会安装成功
安装pip
1、下载pip包
2、安装
# 安装pip
tar -zxvf pip-19.2.3.tar.gz
cd pip-19.2.3
python3 setup.py install
3、报错
报错原因,缺少setuptools包,安装完setuptools包后,重新安装即可
安装setuptools
1、下载
2、安装
unzip setuptools-41.2.0.zip
cd setuptools-41.2.0
python3 setup.py build
python3 setup.py install
通过pip安装第三方包,这里以requests为例:
1、下载相关依赖到单独目录(不知道有什么依赖,在有网的机子上pip install requests,使用打印出来的地址就可以):
wget http://pypi.doubanio.com/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl
wget http://pypi.doubanio.com/packages/e6/60/247f23a7121ae632d62811ba7f273d0e58972d75e58a94d329d51550a47d/urllib3-1.25.3-py2.py3-none-any.whl
wget http://pypi.doubanio.com/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
wget http://pypi.doubanio.com/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl
wget http://pypi.doubanio.com/packages/69/1b/b853c7a9d4f6a6d00749e94eb6f3a041e342a885b87340b79c1ef73e3a78/certifi-2019.6.16-py2.py3-none-any.whl
2、安装 test 目录下所有 .whl 文件,警告不用管
pip3 install test/*
转载自:https://juejin.cn/post/7268602250653843490