zoukankan      html  css  js  c++  java
  • 使用Pip在离线环境安装Python依赖库

    一、安装多个包

    1.有网的服务器

    1.生成requirement.txt文件

    pip freeze >/tmp/wheel_pip/requirements.txt

    这个命令会把当前环境下面的pip安装包名,都放到文件中

    2.打包pip和wheel的whl文件

    pip wheel --wheel-dir=/tmp/wheel_pip pip 
    pip wheel --wheel-dir=/tmp/wheel_pip wheel

    如果没有wheel,就pip install wheel安装

    3. 打包所有依赖包的whl文件

    pip wheel --wheel-dir=/tmp/wheel_pip -r requirements.txt 

    4.下载get-pip文件

    wget https://bootstrap.pypa.io/get-pip.py

    5. 添加到压缩包

    tar cf /tmp/wheel_pip  wheel_pip.tar

    2.离线的服务器

    1.解压压缩包

    wheel_pip.tar复制到离线的服务器,解压

    cd /tmp/ & tar xf wheel_pip.tar ./

    2. 安装pip

    python get-pip.py --no-index --find-links=/tmp/wheel_pip

    3. 安装wheel

    pip install --no-index --find-links=/tmp/wheel_pip wheel

    4. 安装其他包

    pip install --no-index --find-links=/tmp/wheel_pip -r requirements.txt 
    pip install --no-index --find-links=/data1/upload/wheel_pip -r /data1/upload/wheel_pip/requirements.txt 

    三、安装单个包

    1.有网的服务器打包

    pip wheel --wheel-dir=/data1/anchor/lujianxing/  celery 
    #指定包的版本
    pip wheel --wheel-dir=/data1/anchor/lujianxing/  celery==3.1.18 

    wheel包的地址

    ll /data1/anchor/lujianxing/celery-3.1.18-py2.py3-none-any.whl 

    2.同步文件到正式环境

    3. 无网的服务器安装

    cd /data1/upload/
    pip install celery-3.1.18-py2.py3-none-any.whl

    未经许可,请不要转载。

    参考

  • 相关阅读:
    负载均衡
    二叉树反转
    hashMap 和红黑树
    linux c++ 服务器编程,收藏一个测试例子
    某某音乐盒面试
    Linux中的文件i节点
    linux 文件格式压缩
    类string的构造函数、拷贝构造函数和析构函数
    计算二叉树的深度
    string转换为decimal
  • 原文地址:https://www.cnblogs.com/sunshine171/p/12040565.html
Copyright © 2011-2022 走看看