欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

二十四、第三方库自动安装脚本

程序员文章站 2022-07-12 19:47:12
...

一、常用库

二十四、第三方库自动安装脚本二十四、第三方库自动安装脚本
二十四、第三方库自动安装脚本二十四、第三方库自动安装脚本

二、实例

import os
libs = {'pypdf2','matplotlib'}
try:
    for lib in libs:
        os.system('pip install ' + lib)
    print('Successful')
except:
    print('Failed Somehow')

运行结果:
F:\APP-DEV\Anaconda\install\envs\python36\python.exe F:/python学习/第三方库自动安装脚本.py
Collecting pypdf2
Downloading https://files.pythonhosted.org/packages/b4/01/68fcc0d43daf4c6bdbc6b33cc3f77bda531c86b174cac56ef0ffdb96faab/PyPDF2-1.26.0.tar.gz (77kB)
Building wheels for collected packages: pypdf2
Building wheel for pypdf2 (setup.py): started
Building wheel for pypdf2 (setup.py): finished with status ‘done’
Created wheel for pypdf2: filename=PyPDF2-1.26.0-cp36-none-any.whl size=61092 sha256=b0f14c65641b2920d584a92a1b8bdae544b08ce4e4ac798253826cf0e702a3dc
Stored in directory: C:\Users\20468\AppData\Local\pip\Cache\wheels\53\84\19\35bc977c8bf5f0c23a8a011aa958acd4da4bbd7a229315c1b7
Successfully built pypdf2
Installing collected packages: pypdf2
Successfully installed pypdf2-1.26.0
Requirement already satisfied: matplotlib in f:\app-dev\anaconda\install\envs\python36\lib\site-packages (3.1.2)
Requirement already satisfied: python-dateutil>=2.1 in f:\app-dev\anaconda\install\envs\python36\lib\site-packages (from matplotlib) (2.8.0)
Requirement already satisfied: cycler>=0.10 in f:\app-dev\anaconda\install\envs\python36\lib\site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: numpy>=1.11 in f:\app-dev\anaconda\install\envs\python36\lib\site-packages (from matplotlib) (1.17.2)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in f:\app-dev\anaconda\install\envs\python36\lib\site-packages (from matplotlib) (2.4.6)
Requirement already satisfied: kiwisolver>=1.0.1 in f:\app-dev\anaconda\install\envs\python36\lib\site-packages (from matplotlib) (1.1.0)
Requirement already satisfied: six>=1.5 in f:\app-dev\anaconda\install\envs\python36\lib\site-packages (from python-dateutil>=2.1->matplotlib) (1.12.0)
Requirement already satisfied: setuptools in f:\app-dev\anaconda\install\envs\python36\lib\site-packages (from kiwisolver>=1.0.1->matplotlib) (41.6.0.post20191030)
Successful

Process finished with exit code 0