I'm using pip and virtualenv for my python application. I would like to upgrade to a new version of the application without touching the dependencies. When I use pip install -U
, it tries to upgrade all the packages, and even uninstalls and re-installs the same version of a dependency package when there isn't a new version available.
I also tried pip install -U --no-deps
but that seems equivalent to a regular install instead of an upgrade. Is there a combination of flags that will do what I want?
Best Answer
Overview:
pip install
(without-U
)pip install --upgrade --upgrade-strategy only-if-needed
(default in new versions)pip install --upgrade --upgrade-strategy eager
(default in old versions)UPDATE (thanks to @Jether's comment): If you're using the latest version of pip, then updating dependencies only when necessary is now the default behavior, and you don't need to do anything special! The answer below outlines the steps for older versions of pip (which also works for newer versions if you want to be portable).
If you really want to not touch dependencies, then indeed the way to go is
But I think what you'll usually want is to not upgrade dependencies unless it's required. In that case you can use:
This only updates requirements if the package requires a newer version than is installed.