Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to do an AND on search terms in a pip search?

For example, doing:

pip search django toolbar

seems to show all django related packages, even if they have nothing to do with toolbar.

The best I can do is to workaround with:

pip search django toolbar | grep toolbar | grep django


this is better:

pip search toolbar | grep django

and makes my question useless

share|improve this question
my old workaround was silly, with the new one I see it does not matter if there is no AND: just search for what you think is has less matches, and grep away for each other search term – Ciro Santilli 巴拿馬文件 六四事件 法轮功 Nov 24 '12 at 17:59
up vote 1 down vote accepted

In short, you can't.

After the installation of pip, I had a look at site-packages/pip-1.2.1-py2.6.egg/pip/commands/, which is where the search command is implemented.

It uses the XML-RPC interface to PyPi, which is documented at
We can see that the footprint for the search is search(spec[, operator]). The documentation notes:

Arguments for different fields are combined using either "and" (the default) or "or". Example: search({'name': 'foo', 'description': 'bar'}, 'or'). The results are returned as a list of dicts {'name': package name, 'version': package release version, 'summary': package release summary}

Awesome! So this is where we define the search operator! And and is even the default!

Now back to

def search(self, query, index_url):
    pypi = xmlrpclib.ServerProxy(index_url,
    hits ={'name': query, 'summary': query}, 'or')
    return hits

And here we see that the 'or' is hardcoded.

share|improve this answer
and might be a better design choice because it is easier to combine several searches than to filter them – Ciro Santilli 巴拿馬文件 六四事件 法轮功 Nov 20 '12 at 19:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.