CentOS下完全离线安装python3.6.8、pip3、numpy、flask
本文是基于ubuntu系统环境,安装和使用python3.6.8、pip3、numpy、flask
CentOS 7
python 3.6.8
http://rpm.pbone.net/ 下载各种安装包的地址
(1) 安装python3.6.8
下载并安装依赖包 zlib-devel
zlib-devel-1.2.7-17.el7.x86_64.rpm
rpm -ivh zlib-devel-1.2.7-17.el7.x86_64.rpm
下载并安装依赖包 bzip2-devel
bzip2-devel-1.0.6-13.el7.x86_64.rpm
rpm -ivh bzip2-devel-1.0.6-13.el7.x86_64.rpm
下载并安装依赖包 epel-release
epel-release-7-11.noarch.rpm
rpm -ivh epel-release-7-11.noarch.rpm
下载并安装依赖包 ncurses-devel
ncurses-devel-5.9-13.20130511.el7.x86_64.rpm
rpm -ivh ncurses-devel-5.9-13.20130511.el7.x86_64.rpm
下载并安装依赖包 gcc
mpfr-3.1.1-4.el7.x86_64.rpm
libmpc-1.0.1-3.el7.x86_64.rpm
kernel-headers-3.10.0-514.el7.x86_64.rpm
glibc-headers-2.17-157.el7.x86_64.rpm
glibc-devel-2.17-157.el7.x86_64.rpm
cpp-4.8.5-11.el7.x86_64.rpm
gcc-4.8.5-11.el7.x86_64.rpm
# 一定要按照以下的顺序进行安装 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++
libstdc+±4.8.5-11.el7.x86_64.rpm
libstdc+±devel-4.8.5-11.el7.x86_64.rpm
gcc-c+±4.8.5-11.el7.x86_64.rpm
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
官网下载python 3.6.8
Python-3.6.8.tgz
进入下载目录,进行解压
tar -xzvf Python-3.6.8.tgz
进入解压目录
cd Python-3.6.8
设置安装路径并安装
python3 -V
(2) 安装pip
python 3.6.8中自带了pip,所以只需要建立链接就行
ln -s /usr/local/python3.6/bin/pip3.6 /usr/bin/pip
检查pip是否安装成功
pip -V
(3) 安装第三方包numpy
使用pip安装numpy
pip install numpy
离线安装numpy
1. 第一种方式(可以去https://pypi.org/search/?q=numpy的pypi官网搜索包)
#国内镜像 pip3 install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple/
去官网下载numpy安装包.whl文件
numpy-1.16.4-cp36-cp36m-manylinux1_x86_64.whl
打开命令终端
pip install numpy-1.16.4-cp36-cp36m-manylinux1_x86_64.whl
2. 第二种方式
去官网下载numpy安装包.tgz文件
# ".tar.gz"文件解压 tar -xzvf numpy-1.15.0.tar.gz # 进入目录"numpy-1.15.0" cd numpy-1.15.0 # 找到“setup.py”文件,然后安装 python3 setup.py install
(4) pip 命令的使用方法
查看已经安装的包
pip list
(5) pip 离线安装flask
下载flask的安装包
Flask-1.1.1-py2.py3-none-any.whl
查看flask的依赖包
Click>=5.1 Werkzeug>=0.15 Jinja2>=2.10.1 # Jinja2 依赖 MarkupSafe>=0.23 itsdangerous>=0.24
下载flask各种依赖的安装包
Click-7.0-py2.py3-none-any.whl
Werkzeug-0.15.5-py2.py3-none-any.whl
MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
Jinja2-2.10.1-py2.py3-none-any.whl
itsdangerous-1.1.0-py2.py3-none-any.whl
按照下面的顺序,pip安装
pip install Click-7.0-py2.py3-none-any.whl pip install Werkzeug-0.15.5-py2.py3-none-any.whl pip install MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl pip install Jinja2-2.10.1-py2.py3-none-any.whl pip install itsdangerous-1.1.0-py2.py3-none-any.whl pip install Flask-1.1.1-py2.py3-none-any.whl
使用pip list命令,查看flask是否已安装
pip list
(6) pkginfo 查看包依赖关系
$ pip install pkginfo
$ pkginfo -f requires_dist psutil-5.4.5-cp27-none-win32.whl