How to update/upgrade a package using pip?
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Underwater World
--
Chapters
00:00 Question
00:33 Accepted answer (Score 883)
01:13 Answer 2 (Score 83)
01:39 Answer 3 (Score 27)
02:02 Answer 4 (Score 14)
02:50 Thank you
--
Full question
https://stackoverflow.com/questions/4707...
Question links:
[documentation]: https://pip.pypa.io/en/stable/reference/...
Accepted answer links:
[unsafe]: https://dev.to/elabftw/stop-using-sudo-p...
[virtualenv]: https://virtualenv.pypa.io/en/stable/
Answer 2 links:
[pip-review]: https://github.com/jgonggrijp/pip-review
Answer 4 links:
[answer]: https://stackoverflow.com/questions/4707...
[--user]: https://pip.pypa.io/en/stable/reference/...
[virtualenv]: https://virtualenv.pypa.io/en/stable/
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pip
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Underwater World
--
Chapters
00:00 Question
00:33 Accepted answer (Score 883)
01:13 Answer 2 (Score 83)
01:39 Answer 3 (Score 27)
02:02 Answer 4 (Score 14)
02:50 Thank you
--
Full question
https://stackoverflow.com/questions/4707...
Question links:
[documentation]: https://pip.pypa.io/en/stable/reference/...
Accepted answer links:
[unsafe]: https://dev.to/elabftw/stop-using-sudo-p...
[virtualenv]: https://virtualenv.pypa.io/en/stable/
Answer 2 links:
[pip-review]: https://github.com/jgonggrijp/pip-review
Answer 4 links:
[answer]: https://stackoverflow.com/questions/4707...
[--user]: https://pip.pypa.io/en/stable/reference/...
[virtualenv]: https://virtualenv.pypa.io/en/stable/
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pip
#avk47
ACCEPTED ANSWER
Score 1238
This is the way
pip install <package_name> --upgrade
or in short
pip install <package_name> -U
Using sudo will ask to enter your root password to confirm the action, but although common, is considered unsafe.
If you do not have a root password (if you are not the admin) you should probably work with virtualenv.
You can also use the user flag to install it on this user only.
pip install <package_name> --upgrade --user
ANSWER 2
Score 128
For a non-specific package and a more general solution, you can check out pip-review. A tool that checks what packages could/should be updated.
To install:
$ pip install pip-review
Then run:
$ pip-review --interactive
requests==0.14.0 is available (you have 0.13.2)
Upgrade now? [Y]es, [N]o, [A]ll, [Q]uit y
ANSWER 3
Score 37
Use this code in terminal:
python -m pip install --upgrade PACKAGE_NAME
For example I want update pip package:
python -m pip install --upgrade pip
More examples:
python -m pip install --upgrade selenium
python -m pip install --upgrade requests
...
ANSWER 4
Score 20
I use the following line to update all of my outdated packages:
pip list --outdated --format=freeze | awk -F '==' '{print $1}' | xargs -n1 pip install -U
On newer versions of pip the above breaks, use this instead:
pip list --outdated --format=json | jq '.[].name' | xargs -n1 pip install -U