pip的使用

1.簡介:pip是一個安裝和管理 Python 包的工具 ,是easy_install的替代品。python

2.具體使用redis

(1) pip安裝軟件curl

 

# pip install SomePackage(某個包)
  [...]
  Successfully installed SomePackage

(2)pip查看已安裝的軟件工具

 

# pip show --files SomePackage
  Name: SomePackage
  Version: 1.0
  Location: /my/env/lib/pythonx.x/site-packages
  Files:
   ../somepackage/__init__.py
   [...]

(3)pip檢查哪些軟件須要更新ui

 

# pip list --outdated
()

 (4)pip升級軟件url

 

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


 

(5)pip卸載軟件spa

 

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


 

3. pip使用實例

#3.1 安裝redis

# pip install redis
#3.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
#3.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)

 

 

4. 常見錯誤

4.1 ImportError No module named setuptools
請參考《ImportError No module named setuptools解決.net

5. pip參數解釋

# pip --help

Usage:   
  pip <command> [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 <path>           覆蓋的方式記錄verbose錯誤日誌,默認文件:/root/.pip/pip.log
  --log <path>                不覆蓋記錄verbose輸出的日誌.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --timeout <sec>             鏈接超時時間 (默認15秒).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.
  --cert <path>               證書.

 

轉自  http://lib.csdn.net/article/python/1515

相關文章
相關標籤/搜索