Python 3 cheatsheet

Python 3: Packages with pip

10 common Python 3 tasks.

Install a package

Install a package from PyPI.

python -m pip install requests

Install a specific version

Install an exact version instead of the latest one.

python -m pip install requests==2.32.3

Install from a requirements file

Install everything listed in requirements.txt.

python -m pip install -r requirements.txt

Upgrade a package

Install the newest version of a package.

python -m pip install --upgrade requests

Uninstall a package

Remove a package from the environment.

python -m pip uninstall requests

List installed packages

Show packages and their versions.

python -m pip list

Show package details

Show a package's version, dependencies and location.

python -m pip show requests

Find outdated packages

List packages that have newer versions.

python -m pip list --outdated

Write a requirements file

Save the installed packages and exact versions.

python -m pip freeze > requirements.txt

Check for broken dependencies

Verify that installed packages have compatible dependencies.

python -m pip check

Was this page helpful?