当前位置:   article > 正文

Python pip安装包指令用法及安装库检索_强制pip使用whe

强制pip使用whe

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


前言

pip 是python自带的包管理工具,其可以用于Python 安装包的下载、安装、升级及检索功能,可以在命令行中直接进行在线连接到安装库安装所需要的安装包;

所用Python 版本: 3.10.4
自带pip 版本: 22.0.4


一、PIP指令用法:

在线安装方式

  • 在命令行直接输入pip [help]+ 【回车】,其中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.
  cache                       Inspect and manage pip's wheel cache.
  index                       Inspect information available from package indexes.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  debug                       Show information useful for debugging.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --debug                     Let unhandled exceptions propagate outside the main
                              subroutine, instead of logging them to stderr.
  --isolated                  Run pip in an isolated mode, ignoring environment
                              variables and user configuration.
  --require-virtualenv        Allow pip to only run in a virtual environment; exit
                              with an error otherwise.
  -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.
  --no-input                  Disable prompting for input.
  --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 or host:port pair as trusted, even though
                              it does not have valid or any HTTPS.
  --cert <path>               Path to PEM-encoded CA certificate bundle. If provided,
                              overrides the default. See 'SSL Certificate
                              Verification' in pip documentation for more information.
  --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.
  --no-color                  Suppress colored output.
  --no-python-version-warning
                              Silence deprecation warnings for upcoming unsupported
                              Pythons.
  --use-feature <feature>     Enable new functionality, that may be backward
                              incompatible.
  --use-deprecated <feature>  Enable deprecated functionality, that will be removed in
                              the future.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66

常用方法:

  • 显示pip指令的帮助信息: pip [指令] -h
  • 安装库文件: pip install [package name]
  • 下载安装包 pip download [package name]
  • 查看已经安装的包 pip list
  • 查看安装包的详细信息 pip show [package name] # 查看前必须确认安装包已经安装
  • 升级安装包,包括pip pip install -u [package name]

在这里插入图片描述

  • 注意: pip指令是对应相应的python 版本的,通过pip -V 版本检查可以确认pip是否适合当前python版本

在这里插入图片描述

离线安装方式:

除了进行在线安装外,在网络较差或无法在线安装的情况下,可以到第三方库里寻找相应库的Wheel文件下载到本地,然后在本地运行命令行,执行 'cd <文件所在文件夹>’ 进入到文件夹后运行指令 pip install [wheel文件名称] 即可。

二、pip 安装库都有什么,如何检索?

pip 拥有丰富的第三方库支持,但第三方库在哪,如何找到自己想要的库呢?

较简单的方式就是官方pypi网站去查找 Pypi官方库网站

在这里插入图片描述


总结

python 的强大来源于其丰富的第三方库,所以熟练掌握pip指令,才能更好的发挥python的强大功能!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/168497
推荐阅读
相关标签
  

闽ICP备14008679号