2017-10-16 715 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

相關問題