如何获得未安装pip包的简短和详细描述



令我非常失望的是,pip包管理器没有显示任何尚未安装的包的信息。得到任何东西的唯一方法似乎是greppip search XXX |grep -i XXX输出简短描述。

  • Q:有没有一种简单的方法可以获得pip包XXX的详细描述
    (从命令行,无需安装。(

也许使用PyPI中的wgetcurl的聪明方法可以奏效?


编辑:我设法用获得了卷曲一个衬垫

这是Bash一行:

curl -sG -H 'Host: pypi.org' -H 'Accept: application/json' https://pypi.org/pypi/numpy/json | awk -F "description":"" '{ print $2 }' |cut -d ',' -f 1
# NumPy is a general-purpose array-processing package designed to...

然而,一种不同的、更稳健的方式会更可取。

PyPI提供了访问包元数据的API:

  • 简单:来自https://pypi.org/simple/<pkgname>的响应是一个HTML页面,它是下载URL的列表,可以使用任何HTML解析器(如beautifulsouplxml(进行解析。

  • JSON:来自http://pypi.org/pypi/<pkgname>/json的响应是一个JSON字符串,可以使用任何JSON处理工具进行处理。使用requests:的注释示例

In [1]: import requests
In [2]: data = requests.get('https://pypi.org/pypi/lxml/json').json()
In [3]: data['info']['summary']
Out[3]: 'Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API.'
In [4]: data['info']['description']
Out[4]: 'lxml is a Pythonic, mature binding for the libxml2 and libxslt libraries.  Itnprovides safe and convenient access to these libraries using the ElementTreenAPI.nnIt extends the ElementTree API significantly to offer support for XPath,nRelaxNG, XML Schema, XSLT, C14N and much more.nnTo contact the project, go to the `project home pagen<http://lxml.de/>`_ or see our bug tracker atnhttps://launchpad.net/lxmlnnIn case you want to use the current in-development version of lxml,nyou can get it from the github repository atnhttps://github.com/lxml/lxml .  Note that this requires Cython tonbuild the sources, see the build instructions on the project homenpage.  To the same end, running ``easy_install lxml==dev`` willninstall lxml fromnhttps://github.com/lxml/lxml/tarball/master#egg=lxml-dev if you havenan appropriate version of Cython installed.nnnAfter an official release of a new stable series, bug fixes may becomenavailable atnhttps://github.com/lxml/lxml/tree/lxml-4.2 .nRunning ``easy_install lxml==4.2bugfix`` will installnthe unreleased branch state fromnhttps://github.com/lxml/lxml/tarball/lxml-4.2#egg=lxml-4.2bugfixnas soon as a maintenance branch has been established.  Note that thisnrequires Cython to be installed at an appropriate version for the build.nn4.2.5 (2018-09-09)n==================nnBugs fixedn----------nn* Javascript URLs that used URL escaping were not removed by the HTML cleaner.n  Security problem found by Omar Eissa.nnnnn'

命令行的替代方案是使用yolk。使用安装

$ pip install yolk3k

以上lxml查询yolk:的摘要和描述

$ yolk -M lxml -f summary,description
summary: Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API.
description: lxml is a Pythonic, mature binding for the libxml2 and libxslt libraries.  It
provides safe and convenient access to these libraries using the ElementTree
API.
It extends the ElementTree API significantly to offer support for XPath,
RelaxNG, XML Schema, XSLT, C14N and much more.
...

相关内容

  • 没有找到相关文章

最新更新