pip基本命令

发布时间 2023-12-04 13:39:23作者: 马路野狼
  1. Install a Package:

    • Command: pip install package_name
    • Usage: Installs the specified package. You can also specify a version number with package_name==version_number.
  2. Install Packages from a Requirements File:

    • Command: pip install -r requirements.txt
    • Usage: Installs all the packages listed in the specified requirements file (requirements.txt is a common filename).
  3. Upgrade a Package:

    • Command: pip install --upgrade package_name
    • Usage: Upgrades the specified package to the latest version.
  4. Uninstall a Package:

    • Command: pip uninstall package_name
    • Usage: Uninstalls the specified package from the environment.
  5. List Installed Packages:

    • Command: pip list
    • Usage: Lists all packages installed in the current environment along with their versions.
  6. Show Information about a Package:

    • Command: pip show package_name
    • Usage: Displays detailed information about a specific package, including its version, dependencies, and location.
  7. Search for a Package:

    • Command: pip search search_term
    • Usage: Searches the Python Package Index (PyPI) for packages whose name or summary contains the search term.
  8. Freeze Installed Packages:

    • Command: pip freeze
    • Usage: Outputs a list of all installed packages in a requirements format. Often used to create a requirements.txt file.
  9. Check for Packages with Known Issues:

    • Command: pip check
    • Usage: Checks for installed packages with known issues, such as broken dependencies.
  10. Download a Package:

    • Command: pip download package_name
    • Usage: Downloads a package and its dependencies but does not install them.
  11. Install a Package at a Specific Version:

    • Command: pip install package_name==version_number
    • Usage: Installs a specific version of a package.
  12. Upgrade pip Itself:

    • Command: pip install --upgrade pip
    • Usage: Upgrades pip to the latest version.