1. 程式人生 > >pip簡明指南

pip簡明指南

pip常用方法和簡單例項

文章目錄

1、pip安裝包

 $ pip install
<PackageName> #安裝軟體源中最新版本的包 $ pip install <PackageName>==<Version> #安裝指定版本的包

2、pip檢視已安裝的包(包括安裝路徑等詳細資訊)

 $ pip show --files <PackageName>
Name: PackageName
Version:1.0
Location:/my/env/lib/pythonx.x/site-packages
Files:
../PackageName/__init__.py
[...]

3、pip檢查哪些包需要更新

 $ pip list --outdated
PackageName (
Current: 1.0 Latest: 2.0)

4、pip升級包

 $ pip install --upgrade <PackageName>
[...]
PackageName
Found existing installation: PackageName 1.0
Uninstalling PackageName:
Successfully uninstalled SomePackage
Running setup.py install for SomePackage
Successfully installed SomePackage

5、pip解除安裝包

$ pip uninstall <
PackageName> Uninstalling PackageName: /my/env/lib/pythonx.x/site-packages/somepackage Proceed (y/n)? y Successfully uninstalled PackageName

6、pip使用例項

6.1、安裝redis
$ pip install redis
6.2、解除安裝redis
$ pip uninstall redis
Uninstalling redis:
/usr/lib/python2.6/site-packages/redis-2.9.1-py2.6.egg-info

.....省略一些內容....

Proceed (y/n)? y
Successfully uninstalled redis
6.3、檢視待更新包
$ pip list --outdate
pygpgme (Current: 0.1 Latest: 0.3)

pycurl (Current: 7.19.0 Latest: 7.19.3.1)

iniparse (Current: 0.3.1 Latest: 0.4)

7. pip引數解釋

$ pip --help


Usage:


pip [options]


Commands:


install                     安裝包.


uninstall                   解除安裝包.


freeze                      按著一定格式輸出已安裝包列表


list                        列出已安裝包.


show                        顯示包詳細資訊.


search                      搜尋包,類似yum裡的search.


wheel                       Build wheels from your requirements.


zip                         不推薦. Zip individual packages.


unzip                       不推薦. Unzip individual packages.


bundle                      不推薦. Create pybundles.


help                        當前幫助.


General Options:


-h, --help                  顯示幫助.


-v, --verbose               更多的輸出,最多可以使用3次


-V, --version               現實版本資訊然後退出.


-q, --quiet                 最少的輸出.


--log-file                  覆蓋的方式記錄verbose錯誤日誌,預設檔案:/root/.pip/pip.log


--log                      不覆蓋記錄verbose輸出的日誌.


--proxy                    Specify a proxy in the form [user:[email protected]]proxy.server:port.


--timeout                  連線超時時間 (預設15秒).


--exists-action            Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.


--cert                     證書.