默认情况下,pip会搜索包名称和描述。对于某些软件包,这会导致大量的虚假命中,并找到我真正想要的那个是痛苦的。
我怎么告诉pip我只想按姓名搜索?
答案 0 :(得分:5)
好吧,在Linux / OSX上,用一些grep
/ egrep
来做半手动操作并不困难(OSX往往要求你使用egrep进行正则表达式,Linux不这样做)
下面的搜索会返回很多东西(实际上是41,如果你把它推到wc
)。
pip search psycopg
输出的前几行:
gevent-psycopg2 (0.0.3) - pip-installable package for patching psycopg2 to use gevent
django-psycopg2-pool (0.1.1) - A db backend for Django using the gevent psycopg2-pool
pg4nosql (0.4.2) - A simple psycopg2 based wrapper for nosql like database interaction with python.
zope.psycopgda (1.1.1) - Psycopg Database Adapter for Zope 3
qmarkpg (0.2) - A psycopg2 wrapper using the qmark parameters style
但是如果你查看pip输出,你会看到packaname字段倾向于以版本名称终止 - psycopg(1.1.21)
所以,请写下来:
pip search psycopg | egrep "^.*psycopg.*\("
输出:
gevent-psycopg2 (0.0.3) - pip-installable package for patching psycopg2 to use gevent
django-psycopg2-pool (0.1.1) - A db backend for Django using the gevent psycopg2-pool
zope.psycopgda (1.1.1) - Psycopg Database Adapter for Zope 3
psycopg2-managed-connection (1.0.0) - Thread-safe connection manager for psycopg2 connections.
db-psycopg2 (0.0.7) - psycopg2 driver for db
kr-impatient-psycopg2 (2.5.2.dev0) - Python-PostgreSQL Database Adapter
tornado-psycopg2 (0.3.1) - Tornado driver for support asynchronous mode for psycopg2.
psycopg2 (2.6.1) - psycopg2 - Python-PostgreSQL Database Adapter
psycopg2-dateutils (0.1) - Use dateutils.relativedelta to represent PostgreSQL interval types
psycopg2ct (2.4.4) - An implementation of the psycopg2 module using ctypes.
psycopgwrap (1.05) - A wrapper around psycopg2 to make common things easier.
psycopgda (1.0) - Psycopg Database Adapter for Zope 3
psycopg-postgis (0.1.1) - Pyscopg helpers to work with PostGIS.
psycopg2cffi (2.7.2) - .. image:: https://travis-ci.org/chtd/psycopg2cffi.svg?branch=master
psycopg2cffi-compat (1.1) - A Simple library to enable psycopg2 compatability
little_pger (0.65) - A thin layer just a tad above SQL, for use with PostgreSQL and psycopg2, when you want to wrap queries in a convenient way, using plain data structures (but you don't feel like using an ORM, for some reason).
psycopg (1.1.21) - Python-PostgreSQL Database Adapter
psycopg2da (2.0.9) - Python psycopg2 database adapter for Zope
这假定包名中没有括号。
作为可重复使用的bash函数(放入.profile
等):
pipsearchpackagename(){
#a bash function.
pip search $1 | egrep "^.*"$1".*\("
}
答案 1 :(得分:2)
目前无法实现,因为当前实施(点8.1.1)执行了name OR summary
查询hard-coded in pip search command,但PyPI XML RPC支持不同的查询。