Skip to main content

Most Common Uses of the pip Command

Installing a Package

Downloads and installs a package from the Python Package Index (PyPI).

pip install package-name

Installing a Specific Version

Installs a particular version of a package. Useful when your project depends on a specific version to work correctly.

pip install package-name==1.2.3

Uninstalling a Package

Removes an installed package from your system.

pip uninstall package-name

Listing Installed Packages

Displays all packages currently installed in your Python environment, along with their versions.

pip list

Freezing Dependencies

Saves all currently installed packages and their exact versions to a requirements.txt file. Useful when sharing your project so others can replicate your environment.

pip freeze > requirements.txt

Installing from a Requirements File

Installs all packages listed in a requirements.txt file at once. Commonly used when setting up a project someone else created.

pip install -r requirements.txt