What do square brackets mean in pip install?

后端 未结 4 1234
甜味超标
甜味超标 2020-12-01 04:23

I see more and more commands like this:

$ pip install \"splinter[django]\"

What do these square brackets do?

4条回答
  •  鱼传尺愫
    2020-12-01 04:40

    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. The square brackets ([]) are not specific syntax, just convention. Really, you are installing the package named: "splinter[django]".

    An explanation from @chetner:

    The command pip install splinter django would install two packages named splinter and django. 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.

提交回复
热议问题