I’m trying to understand the difference between using pip install -Ur requirements.txt vs pip install -r requirements.txt I noticed that when using the one with -Ur sometimes I get more recent updated packages when compared to using -r. I tried to look it up across the internet but didn’t find a reasonable explanation. Can anyone please explain the difference?
Thanks!
>Solution :
pip’s official documentation says:
-U, --upgradeUpgrade all specified packages to the newest available version. The handling of dependencies depends on the upgrade-strategy used.
So the difference is that pip install -r only installs dependencies, while -Ur also upgrades dependencies, if there is a new version available.
There’s also another reference that says:
Once you’ve got your requirements file, you can head over to a different computer or new virtual environment and run the following:
pip install -r requirements.txt[…]
This tells pip to install the specific versions of all the dependencies listed.
To upgrade your installed packages, run the following:
pip install --upgrade -r requirements.txt