Check if requirements are up to date(检查要求是否是最新的)
问题描述
我正在使用 pip
需求文件 用于保存我的依赖项列表.
I'm using pip
requirements files for keeping my dependency list.
我还尝试遵循管理依赖项的最佳实践,并在需求文件中提供精确的包版本.例如:
I also try to follow best practices for managing dependencies and provide precise package versions inside the requirements file. For example:
Django==1.5.1
lxml==3.0
问题是:有没有办法告诉 Python 包索引中是否有任何更新的包版本可用于 requirements.txt
中列出的包?
The question is: Is there a way to tell that there are any newer package versions available in the Python Package Index for packages listed inside requirements.txt
?
对于这个特定的示例,当前最新的可用版本分别是 Django 和 lxml 的 1.6.2 和 3.3.4.
For this particular example, currently latest available versions are 1.6.2 and 3.3.4 for Django and lxml respectively.
我试过 pip install --upgrade -r requirements.txt
,但它说一切都是最新的:
I've tried pip install --upgrade -r requirements.txt
, but it says that all is up-to-date:
$ pip install --upgrade -r requirements.txt
Requirement already up-to-date: Django==1.5.1 ...
请注意,此时我不想运行实际升级 - 我只想看看是否有可用的更新.
Note that at this point I don't want to run an actual upgrade - I just want to see if there are any updates available.
推荐答案
Pip 内置了这个功能.假设你在你的 virtualenv 类型中:
Pip has this functionality built-in. Assuming that you're inside your virtualenv type:
$ pip list --outdated
psycopg2 (Current: 2.5.1 Latest: 2.5.2)
requests (Current: 2.2.0 Latest: 2.2.1)
$ pip install -U psycopg2 requests
之后,将下载并安装新版本的 psycopg2 和请求.那么:
After that new versions of psycopg2 and requests will be downloaded and installed. Then:
$ pip freeze > requirements.txt
你就完成了.这不是一个命令,但优点是您不需要任何外部依赖项.
And you are done. This is not one command but the advantage is that you don't need any external dependencies.
这篇关于检查要求是否是最新的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:检查要求是否是最新的


基础教程推荐
- 用于分类数据的跳跃记号标签 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 筛选NumPy数组 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01