• 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
      
  • 相关阅读:
    HDU 4489 The King’s Ups and Downs (DP+数学计数)
    HDU 2084 数塔 (水DP)
    CodeForces 706C Hard problem (水DP)
    CodeForces 706B Interesting drink (二分查找)
    CodeForces 706A Beru-taxi (数学计算,水题)
    HDU 4438 Hunters (数学,概率计算)
    机器学习-基础知识
    如何学习-学习理论(A-1)-KOLB学习周期理论
    如何学习-辅助工具
    如何学习-入门之后
  • 原文地址:https://www.cnblogs.com/os-linux/p/15429422.html
Copyright © 2020-2023  润新知