2017-10-16 104 views
5

我看到越来越多这样的命令:方括号在pip安装中意味着什么?

$ pip install "splinter[django]" 

做这些方括号呢?

+0

https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies – Ryan

+0

http://logan.tw/posts/2015/01/01/python-package-manager-pip/ –

+0

注意它*应该*是'pip install'splinter [django]'',以避免模式的任何意外的shell扩展。 – chepner

回答

8

您正在使用的syntax是:

pip install "project[extra]" 

所以你installingsplinter包,其中有django增加的支持。方括号([])不是特定的语法,只是约定。真的,您正在安装名为:"splinter[django]"的软件包。

@chetner的解释:

命令pip install splinter django会安装一个名为splinterdjango两个包。另一方面,splinter[django]安装splinter包的变体,其包含支持django。请注意,它与django程序包本身无关,只是splinter程序包定义的字符串,用于启用特定功能集。

+0

关注您的答案,以便将来的用户受益?例如,“extra”是什么意思? –

+0

好吧,这与“pip install splinter django”有什么不同? –

+2

@BabkenVardanyan该命令将安装两个名为'splinter'和'django'的包。另一方面,'splinter [django]'安装了'splinter'软件包的变体,其中包含对'django'的支持。请注意,它与'django'软件包本身无关,只是'splinter'软件包定义的一个字符串,用于启用特定功能集。 – chepner

相关问题