# first, use the pip freeze command to generate a list of installed packages pip freeze > requirements.txt # next, use the pip install command to upgrade all the packages in the list pip install -r requirements.txt --upgrade
To upgrade all the Python packages that are installed on your system using pip, you can use the pip freeze and pip install commands. The pip freeze command generates a list of all the installed packages and their versions, and the pip install command installs or upgrades a package.
The pip freeze command generates a list of packages and their versions in the format package==version, one package per line. This list is saved to a file called requirements.txt in the example above. You can use any name for this file, but requirements.txt is a common convention.
The pip install command reads the list of packages and their versions from the requirements.txt file and installs or upgrades the packages to the specified versions. The --upgrade option tells pip to upgrade the packages if they are already installed.
*Note that this method will only upgrade packages that are already installed on your system. It will not install new packages. If you want to install new packages, you can add them to the requirements.txt file in the same format as the other packages.
Learn Flask development and learn to build cool apps with our premium Python course on Udemy.