1 min read

Python Pip and Requirements Files

pip is the package installer for Python. You can use it to install packages from the Python Package Index (PyPI) and other indexes.

Basic Commands

Install a Package

pip install package_name

Install a Specific Version

pip install package_name==1.0.4

Uninstall a Package

pip uninstall package_name

List Installed Packages

pip list

Show Package Information

Displays information about a specific package.

pip show package_name

Requirements Files

Requirements files (requirements.txt) are used to specify a list of packages and their versions to be installed. This is crucial for reproducing environments.

Creating a Requirements File

You can save the list of currently installed packages to a file.

pip freeze > requirements.txt

Installing from a Requirements File

To install all packages listed in the file:

pip install -r requirements.txt

Upgrading Packages

To upgrade a package to the newest available version:

pip install --upgrade package_name

Checking for Outdated Packages

pip list --outdated

programming/python/python