There isn't a built-in flag yet. Starting with pip version 22.3, the --outdated and --format=freeze have become mutually exclusive. Use Python, to parse the JSON output:
Copypip --disable-pip-version-check list --outdated --format=json | python -c "import json, sys; print('\n'.join([x['name'] for x in json.load(sys.stdin)]))" | xargs -n1 pip install -U
If you are using pip<22.3 you can use:
Copypip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
For older versions of pip:
Copypip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
The
grepis to skip editable ("-e") package definitions, as suggested by @jawache. (Yes, you could replacegrep+cutwithsedorawkorperlor...).The
-n1flag forxargsprevents stopping everything if updating one package fails (thanks @andsens).
Note: there are infinite potential variations for this. I'm trying to keep this answer short and simple, but please do suggest variations in the comments!
Answer from rbp on Stack OverflowThere isn't a built-in flag yet. Starting with pip version 22.3, the --outdated and --format=freeze have become mutually exclusive. Use Python, to parse the JSON output:
Copypip --disable-pip-version-check list --outdated --format=json | python -c "import json, sys; print('\n'.join([x['name'] for x in json.load(sys.stdin)]))" | xargs -n1 pip install -U
If you are using pip<22.3 you can use:
Copypip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
For older versions of pip:
Copypip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
The
grepis to skip editable ("-e") package definitions, as suggested by @jawache. (Yes, you could replacegrep+cutwithsedorawkorperlor...).The
-n1flag forxargsprevents stopping everything if updating one package fails (thanks @andsens).
Note: there are infinite potential variations for this. I'm trying to keep this answer short and simple, but please do suggest variations in the comments!
To upgrade all local packages, you can install pip-review:
Copy$ pip install pip-review
After that, you can either upgrade the packages interactively:
Copy$ pip-review --local --interactive
Or automatically:
Copy$ pip-review --local --auto
pip-review is a fork of pip-tools. See pip-tools issue mentioned by @knedlsepp. pip-review package works but pip-tools package no longer works. pip-review is looking for a new maintainer.
pip-review works on Windows since version 0.5.
How to UPdate all Python-packages (pip) in one sweep?
how do you upgrade all outdated pip packages?
How can i upgrade all the installed pip packages using one line of code with as less as possible characters?
Pip update all with dependency management
Videos
pip freeze -o > requirements.txt
output:
Usage: pip freeze [options] no such option: -o
i want to convert all the outdated pip packages to a requirements format and contain it into requirements.txt.
With pip there isn't a concept of 'newest stable' as there is in Debian/Ubuntu.
The 'newest stable' packages in Debian/Ubuntu are tested to work correctly with all the other packages in the distribution.
With pip, you can upgrade all the python modules, but you will upgrade all the modules to the latest version available in the repository. It will be your responsibility to verify that everything still continues to work. There may be issues due to new bugs or incompatible changes.
Because of that never upgrade the OS provided python modules with pip (option: --system) unless you're ready to repair the possible breakage.
It can make a lot of sense to upgrade all the modules installed in your user environment, or better inside a virtual environment. The command should be:
pip freeze | awk '{print $1}' | xargs pip install -U
For users of different distributions and other cases, check:
pip help install
since the default behavior (no --user or --system options) changes from Debian derivatives to standard python.
I've tested this on pip2 and pip3 with success although I'm not sure if there's a better way to do it.
pip freeze | sed 's/==.*//' | xargs pip install -U
You may like to add --user after pip freeze and pip install if you only want to upgrade packages installed to your user account instead of the system. If you're upgrading system Python packages you'll need to run the pip install with sudo otherwise you'll likely hit a permission denied error.
Hey guys, I found a neat little project a few months ago and it's been super helpful to me, so I figured that I'd share it here. It's called pip-upgrade-tool and as the title says, it allows for an "upgrade all" mechanic in pip, since it currently doesn't have an official way of doing this. There is the way to upgrade everything by piping pip freeze to grep and cut and xargs, but that doesn't take into account the dependencies that each package has. This project, on the other hand, does take into account dependencies, just like a normal package manager. After installation with pip3 install pip-upgrade-tool, you can just run pip-upgrade in a terminal to upgrade everything. This package can run in and out of virtual environments, and has the ability to exclude packages as well. I actually contributed to it when I first found out about it, and added the ability to use a configuration file for permanent configurations (e.g. permanent excluded packages). Hope you guys find this as useful as I do!
I usually just run the following commands to upgrade both pip2 (=pip by default) and pip3:
sudo -H pip3 install --upgrade pip
sudo -H pip2 install --upgrade pip
You must make sure that you upgrade the version (for Python 2 or 3), which you want to react on the command pip without number, last.
Also please note that this keeps the old packaged versions installed through apt-get or any other package manager, but adds new versions which have nothing to do with the system packages. The pip-installed packages will be preferred, but you should not remove the apt-get-installed ones either, because the package manager can't know that any pip version is installed otherwise.
I think the
pip install --upgrade pip
command does not work properly anymore. The correct command should be:
for Python 3:
python3 -m pip install --upgrade pipfor Python 2:
python2 -m pip install --upgrade pip
P.S. If you want to make sure your other Python packages are also up to date, follow the instructions here.