If you already have a compatible version of package
installed, the accepted answer by user3850 will not upgrade to the latest patch (in my experience, that is).
For example I have django 1.9.8
installed and want to upgrade to the latest patch, which is 1.9.13
, but pip install django~=1.9.0
(or pip install django~=1.9
) tells me requirement already satisfied
(using pip 18.0).
So, in this case we need to add --upgrade
. There are two options that work for me:
pip install django~=1.9.0 --upgrade
and one that I find more readable (based on this answer):
pip install django==1.9.* --upgrade
If using the first option (~=
) make sure to include the "micro" version number (as in "major.minor.micro"). For example, pip install django~=1.9.0 --upgrade
upgrades to 1.9.13
, as desired, but pip install django~=1.9 --upgrade
(i.e. without the .0
) upgrades to 1.11.15
instead.
Note: the lack of a lower bound, e.g. =>1.9.8
, in option 2. should not be an issue because upgrade would give us the latest match anyway.