鱼C论坛

 找回密码
 立即注册
查看: 2742|回复: 0

[技术交流] 【python】使用代码批量更新Python模块

[复制链接]
发表于 2020-10-25 20:51:16 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
升级包其实很简单,就是pip install -U *   
  • 就是你包的名称。不过当包很多的时候就很麻烦了。

    步骤很简单。
    进入cmd (别告诉我你不会)输入 pip list --outdate 命令,查看哪些包需要升级。
    然后复制全部结果,等下会用到。
    打开你的编辑器,什么都行,我用的是jupyter notebook. 输入下面的代码。
    【*】你只需要修改的地方就是 变量info的内容,删除之前的换成你电脑上面需要升级的就行了,很简单。
    【*】升级的速度取决你电脑的网速,模块的数量,以及更新源的地址,我已经提前将源全部改成清华的了,所以更新很快(百度下有很多方法,我这里就不赘述了。)
    【*】希望对你有帮助。
    import os
    
    
    info = """
    attrs             19.3.0     20.2.0       wheel
    beautifulsoup4    4.9.1      4.9.3        wheel
    bleach            3.1.5      3.2.1        wheel
    cffi              1.14.1     1.14.3       wheel
    colorama          0.4.3      0.4.4        wheel
    Eel               0.13.2     0.14.0       sdist
    Faker             4.1.1      4.14.0       wheel
    gevent            20.6.2     20.9.0       wheel
    greenlet          0.4.16     0.4.17       wheel
    iniconfig         1.0.1      1.1.1        wheel
    ipykernel         5.3.2      5.3.4        wheel
    ipython           7.16.1     7.18.1       wheel
    isort             4.3.21     5.6.4        wheel
    jedi              0.17.1     0.17.2       wheel
    jupyter-client    6.1.6      6.1.7        wheel
    jupyter-console   6.1.0      6.2.0        wheel
    jupyter-kite      1.1.0      1.2.0        sdist
    lazy-object-proxy 1.4.3      1.5.1        wheel
    lxml              4.5.2      4.6.1        wheel
    matplotlib        3.3.0      3.3.2        wheel
    more-itertools    8.4.0      8.5.0        wheel
    nbconvert         5.6.1      6.0.7        wheel
    nbformat          5.0.7      5.0.8        wheel
    notebook          6.0.3      6.1.4        wheel
    numpy             1.19.0     1.19.2       wheel
    openpyxl          3.0.4      3.0.5        wheel
    pandas            1.1.0      1.1.3        wheel
    pandocfilters     1.4.2      1.4.3        sdist
    parso             0.7.0      0.8.0        wheel
    Pillow            7.2.0      8.0.1        wheel
    pip               20.2.3     20.2.4       wheel
    prompt-toolkit    3.0.5      3.0.8        wheel
    Pygments          2.6.1      2.7.2        wheel
    PyInstaller       3.6        4.0          sdist
    pylint            2.5.3      2.6.0        wheel
    PyQt5             5.15.0     5.15.1       wheel
    PyQt5-sip         12.8.0     12.8.1       wheel
    pyqt5-tools       5.15.0.1.7 5.15.1.1.7.5 wheel
    PyQtChart         5.15.0     5.15.1       wheel
    PyQtWebEngine     5.15.0     5.15.1       wheel
    pyrsistent        0.16.0     0.17.3       sdist
    PySide2           5.15.0     5.15.1       wheel
    pytest            6.0.1      6.1.1        wheel
    pyzmq             19.0.1     19.0.2       wheel
    qtconsole         4.7.5      4.7.7        wheel
    setuptools        41.2.0     50.3.2       wheel
    shiboken2         5.15.0     5.15.1       wheel
    sip               5.3.0      5.4.0        wheel
    terminado         0.8.3      0.9.1        wheel
    tqdm              4.48.0     4.50.2       wheel
    traitlets         4.3.3      5.0.5        wheel
    urllib3           1.25.9     1.25.11      wheel
    XlsxWriter        1.2.9      1.3.7        wheel
    zope.event        4.4        4.5.0        wheel
    zope.interface    5.1.0      5.1.2        wheel
    """
    
    item = info.replace('wheel', '').replace('sdist', '').split()
    for i in item:
        if i.isalnum():
            print('正在升级:{}'.format(i))
            os.system('pip install -U {}'.format(i))
    附上3张图。
  • cmd_dos.png
    update.png
    3.png
    想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

    GMT+8, 2024-6-28 19:00

    Powered by Discuz! X3.4

    © 2001-2023 Discuz! Team.

    快速回复 返回顶部 返回列表