How to check if python package is latest version programmatically?

后端 未结 7 1701
南旧
南旧 2020-12-18 18:42

How do you check if a package is at its latest version programmatically in a script and return a true or false?

I can check with a script like this:



        
7条回答
  •  一向
    一向 (楼主)
    2020-12-18 18:57

    To just check the latest version on PyPi (for Python 3.6 and up):

    $ pip install requests

    import requests
    
    package = 'django'  # replace with the package you want to check
    response = requests.get(f'https://pypi.org/pypi/{package}/json')
    latest_version = response.json()['info']['version']
    

提交回复
热议问题