Get a list of all the outdated packages
$ pip list --outdatedOpen a command shell by typing ‘powershell’ in the Search Box of the Task bar
Update All Python Packages On Windows
$ pip freeze | %{$_.split('==')[0]} | %{pip install --upgrade $_}Update All Python Packages On Linux
$ pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U Pip can be used to upgrade all packages on either Windows or Linux:
- Output a list of installed packages into a requirements file (requirements.txt):
$ pip freeze > requirements.txt-
Edit requirements.txt, and replace all ‘==’ with ‘>=’. Use the ‘Replace All’ command in the editor.
-
Upgrade all outdated packages:
$ pip install -r requirements.txt --upgradeUpdating All Packages In A Pipenv Environment
The simplest way to update all the unpinned packages in a specific virtual environment created with pipenv is to do the following steps:
Activate the Pipenv shell that contains the packages to be upgraded
$ pipenv shellUpgrade all packages
$ pipenv updateIf a requirements.txt file is not available, you can use the pip show command to output all the requirements of a specified package:
$ pip show <packagename>Automatically create requirements.txt
You can use the following code to generate a requirements.txt file:
$ pip install pipreqs
$ pipreqs /path/to/projectMore info related to pipreqs can be found here. Sometimes you come across pip freeze, but this saves all packages in the environment including those that you don't use in your current project.
@sbugalski Very good and clean solution but always use py(.exe) on Windows. Way less errors ;)
Anyway, here is my version:
Upgrade pip itself first
py -m pip install --upgrade pipSet environment variables to get rid of errors
Update all packages without interruption (expect in case of hard errors)
(pip list --outdated) | Select -Skip 2 | % {py -m pip install --upgrade $($_.split(' ')[0])}