我使用的python 3.6.5自帶pip,故不用再單獨安裝pip,pip在\Python36\Scripts目錄下
1.使用py -3 -m pip 查詢pip的使用指令:
py -3 -m pip
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependencies.
config Manage local and global configuration.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
help Show help for commands.
2.常用的指令
1.pip install:py -3 -m pip install nose #安裝
py -3 -m pip install nose==1.3.0 #指定版本安裝
2.pip install upgrade: py -3 -m pip install -U nose #更新
py -3 -m pip install --upgrade nose #更新
py -3 -m pip install -U pip #pip更新
3.pip show:py -3 -m pip show nose #顯示包所在目錄及資訊
4.pip uninstall:py -3 -m pip uninstall nose #解除安裝
5.pip list:py -3 -m pip list #查詢安裝的清單
6.pip search:pip search nose #搜尋
7.pip freeze: #以需求格式輸出已安裝的包,如到requirements
具體使用方法:pip freeze | tee requirements.txt # 輸出本地包環境至檔案
8.pip install -r requirements.txt #安裝requirements檔案裡的安裝包
9.pip list -o #查詢可更新的包
#通過對比pip freeze和pip list會發現輸出的結果有差别
#是以,pip freeze 為什麼比 pip list 的包少幾個呢?
因為pip , wheel , setuptools 等包,是自帶的而無法(un)install的。
#考慮到pip freeze的用途,是以這些包并沒有顯示。
ps:
如果一定要用pip freeze來顯示所有包,可以加上參數-all,即pip freeze --all
10.download、config、wheel、hash、completion的功能我也不清楚,待查到後再做補充