pythonpipdependency-management

What do square brackets mean in pip install?


I see more and more commands like this:

$ pip install "splinter[django]"

What do these square brackets do?


Solution

  • The syntax that you are using is:

    pip install "project[extra]"
    

    In your case, you are installing the splinter package which has the added support for django.

    An explanation from @chepner:

    pip install splinter django would install two packages named splinter and django.

    pip install splinter[django], on the other hand, installs a variant of the splinter package which contains support for django.

    Note that it has nothing to do with the django package itself, but is just a string defined by the splinter package for a particular feature set that gets enabled. How the argument django is interpreted depends on the build system, but any setuptools-based build system (including most instances of setup.py) will likely just use them as a hook for optional dependencies.