Skip to content

PIP

一句话解释

pip 是 Python's 包 installer, used 到 安装 and manage 第三-party 包 从 PyPI.

用大白话说

pip (Pip Installs Packages) is Python's standard package manager. It installs packages from PyPI (Python Package Index), a repository of thousands of third-party libraries.

Common commands:

  • pip 安装 package_name — install a package
  • pip 安装 package_name==1.2.3 — install a specific version
  • pip 卸载 package_name — remove a package
  • pip 列表 — show installed packages
  • pip freeze > 需求.txt — save dependencies to a file
  • pip 安装 -r 需求.txt — install from a file

Always use pip inside a virtual environment to avoid polluting the system Python. Modern Python (3.4+) includes pip automatically.

示例

bash
# Install a package
pip install requests

# Install a specific version
pip install django==4.2

# Save dependencies
pip freeze > requirements.txt

# Install from requirements
pip install -r requirements.txt

# List installed packages
pip list

pip 安装, 移除, and 列表 Python 包 从 PyPI. Use 需求.txt 到 track dependencies.

常见混淆

  • 容易混淆的对象: npm

    关键区别: pip 是 包 manager for Python (安装 从 PyPI). npm 是 包 manager for JavaScript/节点.js (inst#安装 从 npm registry). 它们 serve 相同 purpose for 不同 ecosystems.

相关术语

相关资源

相关课程

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表