• Python第三方库离线安装


    机器A:能联网

    机器B:内网

    Python第三方库官网

    机器A:

    1. 在python虚拟环境中安装需要的第三方库

      [root@i-h0xe1oiq data]# mkvirtualenv -p /usr/local/bin/python3.9 env39
      (env39) [root@i-h0xe1oiq data]# pip3.9 install pymysql
      (env39) [root@i-h0xe1oiq data]# pip3.9 install requests
      
    2. 导出第三方库名到文件

      (env39) [root@i-h0xe1oiq data]# pip3.9 freeze >requirements.txt
      (env39) [root@i-h0xe1oiq data]# cat requirements.txt 
      certifi==2021.10.8
      charset-normalizer==2.0.7
      idna==3.3
      PyMySQL==1.0.2
      requests==2.26.0
      urllib3==1.26.7
      
    3. 下载离线包

      (env39) [root@i-h0xe1oiq data]# pip3.9 download -d packages -r requirements.txt
      (env39) [root@i-h0xe1oiq data]# ll
      total 8
      drwxr-xr-x 2 root root 4096 Oct 20 16:22 packages
      -rw-r--r-- 1 root root  103 Oct 20 16:21 requirements.txt
      (env39) [root@i-h0xe1oiq data]# ll packages/		# 下载的包都在packages目录下
      total 492
      -rw-r--r-- 1 root root 149195 Oct 20 16:22 certifi-2021.10.8-py2.py3-none-any.whl
      -rw-r--r-- 1 root root  38247 Oct 20 16:22 charset_normalizer-2.0.7-py3-none-any.whl
      -rw-r--r-- 1 root root  61160 Oct 20 16:22 idna-3.3-py3-none-any.whl
      -rw-r--r-- 1 root root  43828 Oct 20 16:22 PyMySQL-1.0.2-py3-none-any.whl
      -rw-r--r-- 1 root root  62251 Oct 20 16:22 requests-2.26.0-py2.py3-none-any.whl
      -rw-r--r-- 1 root root 138764 Oct 20 16:22 urllib3-1.26.7-py2.py3-none-any.whl
      
    4. 将packages目录和requirements.txt文件复制到机器B上

    机器B:

    1. 安装第三方库

      [root@VM-8-6-centos data]# pip3.6 install --no-index --find-links=packages -r requirements.txt
      Collecting certifi==2021.10.8 (from -r requirements.txt (line 1))
      Collecting charset-normalizer==2.0.7 (from -r requirements.txt (line 2))
      Collecting idna==3.3 (from -r requirements.txt (line 3))
      Collecting PyMySQL==1.0.2 (from -r requirements.txt (line 4))
      Collecting requests==2.26.0 (from -r requirements.txt (line 5))
      Collecting urllib3==1.26.7 (from -r requirements.txt (line 6))
      Installing collected packages: certifi, charset-normalizer, idna, PyMySQL, urllib3, requests
      Successfully installed PyMySQL-1.0.2 certifi-2021.10.8 charset-normalizer-2.0.7 idna-3.3 requests-2.26.0 urllib3-1.26.7
      
  • 相关阅读:
    phonegap_android配置文档
    JQueryMobile + PhoneGap 经验总结
    nand ECC 算法记录
    u-boot 2016.05 添加自己的board 以及config.h
    git commit 多行注释方法说明
    Ubuntu 下新建用户后无法sudo
    QT4.8.5 QComboBox 增加选择菜单记录
    Linux GPIO控制方法
    Qt5 can't find -LGL
    windows 端搭建nfs 服务器
  • 原文地址:https://www.cnblogs.com/os-linux/p/15429422.html
Copyright © 2020-2023  润新知