• [Python自学] requirements批量安装依赖


    一、从开发环境导出依赖

    在虚拟环境中运行命令:

    (venv_1) [root@centos-venv-fb ~]# pip3 freeze > ~/requirements.txt

    可以将当前虚拟环境的所有依赖包导入到requirements.txt文件中。

    (venv_1) [root@centos-venv-fb ~]# cat requirements.txt 
    Django==2.2.8
    pytz==2019.3
    sqlparse==0.3.0
    beautifulsoup4==4.6.3
    h5py==2.8.0
    djangorestframework==3.11.0
    redis==3.3.11
    uWSGI==2.0.18

    二、在发布环境安装所有依赖

    进入发布虚拟环境:

    [root@centos-venv-fb ~]# workon venv_fb
    (venv_fb) [root@centos-venv-fb ~]# 

    查看当前已安装依赖列表:

    (venv_fb) [root@centos-venv-fb ~]# pip3 list
    Package    Version
    ---------- -------
    pip        20.0.2 
    setuptools 45.1.0 
    wheel      0.34.1 

    安装requirements.txt中的依赖:

    (venv_fb) [root@centos-venv-fb ~]# pip3 install -i https://pypi.douban.com/simple/ -r requirements.txt
    Looking in indexes: https://pypi.douban.com/simple/
    Collecting Django==2.2.8
      Using cached https://pypi.doubanio.com/packages/d3/d0/ef75c788627f4218a8d08dccdf4ebc91f5b83c48d09ec8f2a3db9610014b/Django-2.2.8-py3-none-any.whl (7.5 MB)
    Collecting pytz==2019.3
      Downloading https://pypi.doubanio.com/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl (509 kB)
         |████████████████████████████████| 509 kB 1.7 MB/s 
    Collecting sqlparse==0.3.0
      Downloading https://pypi.doubanio.com/packages/ef/53/900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/sqlparse-0.3.0-py2.py3-none-any.whl (39 kB)
    Collecting beautifulsoup4==4.6.3
      Downloading https://pypi.doubanio.com/packages/21/0a/47fdf541c97fd9b6a610cb5fd518175308a7cc60569962e776ac52420387/beautifulsoup4-4.6.3-py3-none-any.whl (90 kB)
         |████████████████████████████████| 90 kB 2.7 MB/s 
    Collecting h5py==2.8.0
      Using cached https://pypi.doubanio.com/packages/4f/3f/724834613239667a92d3b8b6b8fdef1c93d6f57d008cacc46e6b9ebdc486/h5py-2.8.0-cp37-cp37m-manylinux1_x86_64.whl (2.8 MB)
    Collecting djangorestframework==3.11.0
      Downloading https://pypi.doubanio.com/packages/be/5b/9bbde4395a1074d528d6d9e0cc161d3b99bd9d0b2b558ca919ffaa2e0068/djangorestframework-3.11.0-py3-none-any.whl (911 kB)
         |████████████████████████████████| 911 kB 24.0 MB/s 
    Collecting redis==3.3.11
      Downloading https://pypi.doubanio.com/packages/32/ae/28613a62eea0d53d3db3147f8715f90da07667e99baeedf1010eb400f8c0/redis-3.3.11-py2.py3-none-any.whl (66 kB)
         |████████████████████████████████| 66 kB 9.9 MB/s 
    Processing ./.cache/pip/wheels/53/be/45/34e8f5c0fa3dafd17e4c34b2d048ffc82a5abc6910eed34929/uWSGI-2.0.18-cp37-cp37m-linux_x86_64.whl
    Collecting six
      Downloading https://pypi.doubanio.com/packages/65/eb/1f97cb97bfc2390a276969c6fae16075da282f5058082d4cb10c6c5c1dba/six-1.14.0-py2.py3-none-any.whl (10 kB)
    Collecting numpy>=1.7
      Downloading https://pypi.doubanio.com/packages/63/0c/0261693cc3ad8e2b66e66dc2d2676a2cc17d3efb1c58a70db73754320e47/numpy-1.18.1-cp37-cp37m-manylinux1_x86_64.whl (20.1 MB)
         |████████████████████████████████| 20.1 MB 4.4 MB/s 
    Installing collected packages: pytz, sqlparse, Django, beautifulsoup4, six, numpy, h5py, djangorestframework, redis, uWSGI
    Successfully installed Django-2.2.8 beautifulsoup4-4.6.3 djangorestframework-3.11.0 h5py-2.8.0 numpy-1.18.1 pytz-2019.3 redis-3.3.11 six-1.14.0 sqlparse-0.3.0 uWSGI-2.0.18

    再次查看安装好的依赖:

    (venv_fb) [root@centos-venv-fb ~]# pip3 list
    Package             Version
    ------------------- -------
    beautifulsoup4      4.6.3  
    Django              2.2.8  
    djangorestframework 3.11.0 
    h5py                2.8.0  
    numpy               1.18.1 
    pip                 20.0.2 
    pytz                2019.3 
    redis               3.3.11 
    setuptools          45.1.0 
    six                 1.14.0 
    sqlparse            0.3.0  
    uWSGI               2.0.18 
    wheel               0.34.1 

  • 相关阅读:
    函数参数传递
    C# 串口发送 陷阱,必须知道的坑
    Altera Quartus 13.1 仿真工具路径错误问题解决 Can't launch the ModelSim-Altera software
    Altium Designer 快速修改板子形状为Keep-out layer大小
    Altium Designer 敷铜间距设置,真实有效
    VS2012,VS2013启用SQLite的Data Provider界面显示
    Sqlite 设置外键级联更新
    Sqlite 设置默认时间为本地时间
    FPGA学习笔记之Altera FPGA使用JIC文件配置固化教程(转)
    FPGA学习记录
  • 原文地址:https://www.cnblogs.com/leokale-zz/p/12242804.html
Copyright © 2020-2023  润新知