zoukankan      html  css  js  c++  java
  • 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
      
  • 相关阅读:
    git命令
    Java开发中的23种设计模式详解
    Linux下简单基本操作【备查】
    微信|公众平台开发者平台
    MyEclipse老是弹出problem occurred窗口
    spring 工具包怎么下载
    MyEclipse8.6启动后提示内存不足的解决方案(亲测,完美解决)
    bzoj2440,luoguP4318 完全平方数
    hdu5528
    CF1076E Vasya and a Tree
  • 原文地址:https://www.cnblogs.com/os-linux/p/15429422.html
Copyright © 2011-2022 走看看