+2 votes
2 views
in Python by (4.1k points)

How to upgrade all python packages in one go using pip?

3 Answers

0 votes
by (46.1k points)
edited by

To upgrade all local packages with a single syntax we can use pip-review

$ pip install pip-review
$ pip-review --local --interactive

Mention the doubts in comments.

0 votes
by (107k points)
edited by
  • To upgrade all the local packages, you can use pip-review. Below is the command for doing that:-

$ pip install pip-review 

$ pip-review --local --interactive

  • pip-review is a fork of pip-tools. 
  • You can also use the way I am mentioning below:-

pip install -U $(pip freeze | awk '{split($0, a, "=="); print a[1]}')

  • Here -U option (or --upgrade) for pip install can take multiple arguments. And the subshell finds all the installed python packages using pip freeze and pipes the results to awk.

You can use the following video tutorials to clear all your doubts:-

0 votes
by (20.3k points)

You can try using the following Python code. Unlike pip freeze, this will not print warnings and FIXME errors.

 For pip < 10.0.1, try this:

import pip

from subprocess import call

packages = [dist.project_name for dist in pip.get_installed_distributions()]

call("pip install --upgrade " + ' '.join(packages), shell=True)

And, For pip >= 10.0.1, try this:

import pkg_resources

from subprocess import call

packages = [dist.project_name for dist in pkg_resources.working_set]

call("pip install --upgrade " + ' '.join(packages), shell=True)

Related questions

+3 votes
2 answers
0 votes
1 answer
+3 votes
2 answers
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...