pip相关常用命令

localhost:python kendo$ pip --help

Usage:  
  pip <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  config                      Manage local and global configuration.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.
                              以隔离的方式运行pip,即忽略pip的全局和用户配置
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to
                              WARNING, ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.附加日志的详细路径
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.指定代理
  --retries <retries>         Maximum number of retries each connection should attempt (default 5 times).
                              每个链接最大的失败重试次数,默认5
  --timeout <sec>             Set the socket timeout (default 15 seconds).设置套接字超时,默认15
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup,
                              (a)bort.
  --trusted-host <hostname>   Mark this host as trusted, even though it does not have valid or any HTTPS.
                              强制设置hostname为受信任  
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file containing the private key and the
                              certificate in PEM format.SSL客户端证书路径
  --cache-dir <dir>           Store the cache data in <dir>.存储缓存数据的地址
  --no-cache-dir              Disable the cache.禁用缓存
  --disable-pip-version-check
                              Don't periodically check PyPI to determine whether a new version of pip is available
                              for download. Implied with --no-index. 禁止定期检查包更新
  --no-color                  Suppress colored output 抑制彩色输出
# 自更新
shell> pip install -U pip

# 更新pip
shell> python -m pip install --upgrade pip

# 更新/升级package
shell> pip install --upgrade package
# 升级所有可以升级的包
shell> pip install pip-review
shell> pip-review --local --interactive

# 通过索引搜索包
shell> pip search package

# 下载包
shell> pip download package

 # 下载并安装包,默认安装最新的
shell> pip install package
# 下载并安装指定版本的package
shell> pip install package==2.2

# 列举出当前环境安装的已安装包
shell> pip list
# 检查哪些包需要更新
shell> pip list --outdated
#格式化列出当前环境已安装的包,packagename==version
shell> pip freeze

#卸载包
shell> pip uninstall package

# 显示已安装的包的摘要信息
shell> pip show package
# 显示已安装的包的详细信息(摘要+文件信息)
shell> pip show --files package
#
shell> pip check package
# 管理本地和全局配置
shell> pip config [edit|get|list|set|unset]

# 打包命令,wheel-dir 为wheel 输出文件夹,后面接项目文件夹(即包含setup.py的文件夹)
shell> pip wheel --wheel-dir=~/wheel_dir ./
# 安装.whl
shell> pip install xxx.whl
# 计算归档文件的哈希值
shell> pip hash manage.py

# 当前用户bash命令行补全
shell> pip completion --bash >> ~/.profile
# 当前用户zsh命令行补全
pip completion --zsh >> ~/.zprofile

Leave Comment

电子邮件地址不会被公开。 必填项已用*标注