pip3 常见用法总结

用法总览

pip3 --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.
  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.
  -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).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --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.
  --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.
  --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.

安装相关

安装指定包的最新版
pip3 install pkg_name
安装制定包的指定版本
pip3 install pkg_name==version

$ pip3 install django==2.0.5
移除指定包
pip3 uninstall pkg_name
在 PyPI 上模糊查找相关包
pip3 search pkg_name

查看相关

查看所有已安装的包
pip3 list

形如:
amqp (1.4.9)
anyjson (0.3.3)
asn1crypto (0.24.0)
查看指定包的相关信息
pip3 show pkg_name

$ pip3 show django
Name: Django
Version: 2.1.4
Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Home-page: https://www.djangoproject.com/
Author: Django Software Foundation
Author-email: [email protected]
License: BSD
Location: /home/ezreal/.local/lib/python3.6/site-packages
Requires: pytz

freeze 的使用

列出所有已安装包
pip3 freeze

形如:
vine==1.1.4
virtualenv==16.1.0
youtube-dl==2018.9.10
生成 requirements.txt 文件
pip3 freeze > requirements.txt

猜你喜欢

转载自blog.csdn.net/weixin_37641832/article/details/85248058