Python-第三方库安装

目录

看见更大的Python世界

安装Python库第三方库


看见更大的Python世界

Python社区

>20万个第三方库 https://pypi.org/

PyPI

  • PyPI:Python Package Index
  • PSF维护的展示全球Python计算生态的主站
  • 学会检索并利用PyPI,找到合适的第三方库开发程序

实例:开发与区块链相关的程序

  1. 在pypi.org搜索blockchain
  2. 挑选适合开发目标的第三方库作为基础
  3. 完成自己需要的功能

安装Python库第三方库

三种方法

  • 方法1(主要方法):使用pip命令
  • 方法2: 集成安装方法
  • 方法3:文件安装方法

第三方库的pip安装方法

  • 主要方法,适合99%以上的情况
  • 适合Windows、Mac和Linux等操作系统
  • 未来获取第三方库的方式,目前主要方式
  • 需要联网安装
C:\Users\Administrator>pip -h

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.
  debug                       Show information useful for debugging.
  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 or host:port pair 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.
  --no-color                  Suppress colored output

重要的pip命令

  • pip install <第三方库名>    安装指定的第三方库
  • pip install -U <第三方库名>    使用-U标签更新已安装的指定第三方库
  • pip uninstall <第三方库名>    卸载指定的第三方库
  • pip download <第三方库名>    下载但不安装指定的第三方库
  • pip show <第三方库名>    列出某个指定第三方库的详细信息
  • pip search <关键词>    根据关键词在名称和介绍中搜索第三方库
  • pip list     列出当前系统已经安装的第三方库

第三方库的集成安装方法

集成安装:结合特定Python开发工具的批量安装

Anaconda:https://www.anaconda.com/

  • 支持近800个第三方库
  • 包含多个主流工具
  • 适合数据计算领域开发

第三方库的文件安装方法

为什么有些第三方库用pip可以下载,但无法安装?

  • 某些第三方库pip下载后,需要编译再安装
  • 如果操作系统没有编译环境,则能下载但不能安装
  •  可以直接下载编译后的版本用于安装吗?

UCI

https://www.lfd.uci.edu/~gohlke/pythonlibs/

本文仅为学习Python记录,资料来源于中国大学MOOC《Python语言设计》—嵩天

猜你喜欢

转载自blog.csdn.net/cheng6023/article/details/102619062
今日推荐