pip是python的包管理工具,pip庫中內建了很多python的開源工具包,在使用的時候直接運行pip install就可以下載並安裝註冊到python模組內,下文將會討論centos中如何安裝pip。
一、安裝pip命令
下載pip安裝包:
[root@web1 xxx]# wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz
解壓tar包:
[root@web1 xxx]# tar -vxf setuptools-1.4.2.tar.gz
進入解壓包,並運行安裝命令:
[root@web1 xxx]# cd setuptools-1.4.2[root@web1 xxx]# python2.7 setup.py install
安裝完成後,最後安裝pip:
[root@web1 xxx]# easy_install-2.7 pip
檢測是否已經安裝成功:
[root@web1 xxx]# pip --versionpip 1.2 from /usr/local/lib/python2.7/site-packages/pip-1.2-py2.7.egg (python 2.7)
二、pip常用命令
1、查看pip使用協助:
[root@web1 xxx]# pip helpUsage: pip COMMAND [OPTIONS] --version show program's version number and exit -h, --help Show help -v, --verbose Give more output -q, --quiet Give less output --log <FILENAME> Log file where a complete (maximum verbosity) record will be kept --proxy <PROXY> Specify a proxy in the form user:passwd@proxy.server:port. Note that the user:password@ is optional and required only if you are behind an authenticated proxy. If you provide user@proxy.server:port then you will be prompted for a password. --timeout <SECONDS> Set the socket timeout (default 15 seconds) --exists-action <EXISTS_ACTION> Default action when a path already exists. Use this option more than one time to specify another action if a certain option is not available. Choices: (s)witch, (i)gnore, (w)ipe, (b)ackupCommands available: bundle: Create pybundles (archives containing multiple packages) freeze: Output all currently installed packages (exact versions) to stdout help: Show available commands install: Install packages search: Search PyPI uninstall: Uninstall packages unzip: Unzip individual packages zip: Zip individual packages
2、pip安裝python包
[root@web1 xxx]# pip install 安裝包名
3、pip卸載已安裝的包
[root@web1 xxx]# pip uninstall 包名
4、其它常用命令
freeze: 查看已經安裝的python包help: FAQ查看pip協助search: Search PyPIunzip: 解壓一個包zip: 壓縮一個已經安裝的包