本文介绍了使用pip命令从require.txt升级python包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用pip命令从require.txt文件升级所有的python包?



尝试使用以下命令

  $ pip install --upgrade -r requirements.txt 

由于python包后缀有版本号( Django == 1.5.1 ),它们似乎没有升级。有没有比手动编辑requires.txt文件更好的方法?



编辑



正如Andy在答案包中提到的那样被固定在一个特定的版本,所以不可能通过pip命令升级包。



但是,我们可以用 pip-tools 使用以下命令。

  $ pip-review  - auto 

这将自动从Require.txt升级所有包(请确保安装 pip-tools 使用pip install命令)

解决方案

您的要求文件已到特定版本。如果您的要求设置为该版本,则不应尝试升级到这些版本。如果您需要需要进行升级,则需要切换到需求文件中的未固定版本。



示例:

  lxml> = 2.2.0 

这会将lxml升级到比2.2.0更新的版本。

  lxml> = 2.2.0,< 2.3.0 

这将升级lxml到2.2.0和2.3.0之间的最新版本。 >

How do I upgrade all my python packages from requirements.txt file using pip command?

tried with below command

$ pip install --upgrade -r requirements.txt

Since, the python packages are suffixed with the version number (Django==1.5.1) they don't seem to upgrade. Is there any better approach than manually editing requirements.txt file?

EDIT

As Andy mentioned in his answer packages are pinned to a specific version, hence it is not possible to upgrade packages through pip command.

But, we can achieve this with pip-tools using the following command.

$ pip-review --auto

this will automatically upgrade all packages from requirements.txt (make sure to install pip-tools using pip install command).

解决方案

No. Your requirements file has been pinned to specific versions. If your requirements are set to that version, you should not be trying to upgrade beyond those versions. If you need to upgrade, then you need to switch to unpinned versions in your requirements file.

Example:

lxml>=2.2.0

This would upgrade lxml to any version newer than 2.2.0

lxml>=2.2.0,<2.3.0

This would upgrade lxml to the most recent version between 2.2.0 and 2.3.0.

这篇关于使用pip命令从require.txt升级python包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 15:41