Skip to content

Latest commit

 

History

History
87 lines (62 loc) · 2.93 KB

pip.md

File metadata and controls

87 lines (62 loc) · 2.93 KB

PIP Commands

This guide outlines common PIP commands for managing Python packages.

  • Install package:

    pip install package-name

    This command installs the specified Python package.

  • Create or update a requirements file:

    pip freeze > requirements.txt

    This command generates a requirements.txt file containing a list of installed packages and their versions. You can use this file to recreate the environment or share package dependencies with others.

  • Attempt to upgrade all packages:

    pip install --upgrade $(pip freeze | cut -d '=' -f 1)

    This command attempts to upgrade all installed packages to their latest versions. It first generates a list of currently installed packages (excluding their versions) using pip freeze, then attempts to upgrade them using pip install --upgrade.

  • Install specific package version:

    pip install package-name==version

    This command installs a specific version of a package. Replace package-name with the name of the package and version with the desired version.

  • Uninstall package:

    pip uninstall package-name

    This command uninstalls the specified package from the Python environment.

  • List installed packages:

    pip list

    This command lists all packages installed in the Python environment along with their versions.

  • Search for packages:

    pip search search-term

    This command searches the Python Package Index (PyPI) for packages matching the specified search term.

  • Show information about a package:

    pip show package-name

    This command displays detailed information about the specified package, including its version, dependencies, and installation location.

  • Install package from a requirements file:

    pip install -r requirements.txt

    This command installs all packages listed in a requirements.txt file. It's useful for recreating the same environment on another machine or sharing dependencies with others.

  • Install package in development mode:

    pip install -e path/to/package

    This command installs a package in "editable" or "development" mode. Changes to the source code are immediately reflected in the installed package without the need to reinstall it.

  • Install packages globally:

    pip install package-name --user

    This command installs the specified package globally for the current user. It's useful when you don't have administrative privileges or want to keep packages separate from the system Python installation.

  • Install packages in a specific directory:

    pip install package-name --target /path/to/directory

    This command installs the specified package in the specified directory instead of the default Python installation directory.