2016-02-10 22 views
7

Varsayılan olarak pip, hem paket adlarını hem de açıklamalarını arar. Bazı paketler için bu çok sayıda sahte isabetle sonuçlanır ve aslında istediğim şeyi bulmak acıdır.Pip paketini yalnızca isme göre nasıl ararım?

Pipeye nasıl söylüyorum sadece isme göre aramak istiyorum?

+3

böyle bir şey yapabilirsiniz: (.profile koymak veya benzeri) bir yeniden kullanılabilir bash fonksiyonu olarak

'pip arama Numpy | awk '{print $ 1}' | grep numpy ' – ziky

+0

ancak' yolk -S name = package_name ' –

cevap

2

Şu anda mümkün değildir, çünkü geçerli uygulama (pip 8.1.1) name OR summary sorguyu hard-coded in pip search command yapsa da, PyPI XML RPC farklı sorguları desteklemektedir.

+0

Tamam'ı kullanabilirsiniz. Duymak istediğim şey değil, teşekkürler. – Andrew

4

Eh, Linux/OSX üzerinde bir şey yapmak için zor bir şey ile grep/egrep (OSX size regex kullanmak için tr, Linux gerektirmez) eğilimindedir.

Aşağıdaki arama çok fazla şey döndürür (aslında wc'a aktarırsanız). çıktıya ait

pip search psycopg

ilk birkaç satır:

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 

Ama packaname alan sürüm adları ile sona eğiliminde olduğunu görüyoruz Eğer pip çıkışında bakarsak - psycopg (1.1.21)

Yani, bunun yerine yazma:

pip search psycopg | egrep "^.*psycopg.*\("

çıkışı:

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 

Bu tabii, paket adı içindeki hiçbir parantez olduğunu varsayar. linux üzerinde

pipsearchpackagename(){ 
    #a bash function. 
    pip search $1 | egrep "^.*"$1".*\(" 
} 
+0

Tamamlamak için, paketin tam adını aramanız gerektiğinde, 'pip arama psycopg | egrep "^ psycopg \" ' (sorgu dizesiyle başlar ve herhangi bir boşluk içermez). –

İlgili konular