北理网课 - Python语言程序设计 - 8.3 Python第三方库安装

版权声明:本文为博主原创文章,转载请留言通知。 https://blog.csdn.net/silent0001/article/details/88901738

一、看见更大的Python世界

我们可以在https://PyPI.org上来访分多打13万的Python第三方库:

-PyPI:Python Package Index

-PSF维护的展示全球Python计算生态的主站

-学会检索并利用PyPI,找到合适的第三方库开发程序

---------------------------------------------------------------------------------------------------------------------------

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

-第一步:在pypi.org搜索biockchain

-第二部:挑选适合开发目标的第三方库作为基础

-第三部:完成自己需要的功能

图:

---------------------------------------------------------------------------------------------------------------------------

安装第三方库的方法

-方法1(主要方法):使用pip命令

-方法2:集成安装方法

-方法3:文件安装方法

=======================================================================

二、第三方库pip的安装方法

用pip安装第三方库,需要在命令行中执行。在Windows、Mac OS、Linux下可以执行。

C:\Users\Dr.Jexus>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.
  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.
  --no-color                  Suppress colored output

输入pip -h后,显示出以上结果,可以看看结果。

使用pip安装第三方库的方法:

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

这是主要方法,适合99%以上的情况

-适合Windows、Mac OS、Linux等操作系统

-未来获取第三方库的方式,目前的主要方式

-适合99%以上的情况,需要联网安装

=======================================================================

三、第三方库的集成安装方法

结合特定的Python的开发工具,批量的安装一批库

推荐一个程序:Anaconda(https://www.continuum.io

-里面支持近800多个第三方库

-包含多个主流工具

-适合数据计算领域开发

=======================================================================

四、第三方库的文件安装方法

文件安装方法

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

-某些第三方库pip下载后,需要编译再安装

-如果操作系统没有编译环境,则能下载但不能安装

-可以直接下载编译后的版本用于安装吗?

此时有一个网站:http://www.lfd.uci.edu/~gohlke/pythonlibs/这个是UCI页面,这是加州大学欧文分校维护的一个页面(Windows操作系统),这是一批可以下载,但是要经过编译再安装的第三方库的直接编译后的版本

---------------------------------------------------------------------------------------------------------------------------

实例:安装wordcloud库

-步骤1:在UCI页面上搜索wordcloud

-步骤2:下载编译后的对应版本文件

-步骤3:使用pip install <文件名>安装

完成!

 

(根据北理讲师嵩天发表,仅个人整理,出现错误可以回复,我会修改的)

猜你喜欢

转载自blog.csdn.net/silent0001/article/details/88901738