所用系统: centos-6.7
系统自带Python版本 :Python 2.6.6
1. pip是什么?
-- pip是一个安装和管理Python 包的工具,是easy_install的替代品.
2.pip安装步骤:
1)下载pip(直接使用wget从网站下载)
# wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate
2)pip安装
#tar -xf pip-1.5.4.tar.gz
#cd pip-1.5.4
#python setup.py install
在安装pip的时候容易出错,报错如下:
[root@1e supervisor-3.0]# python setup.py install Traceback (most recent call last): File "setup.py", line 31, in <module> from setuptools import setup, find_packages ImportError: No module named setuptools
分析: 此提示是缺少setuptools,我们可以从官网下载工具进行安装
下载地址: https://pypi.python.org/pypi/setuptools#downloads
下载的版本是setuptools-36.27.zip 直接解压就可以安装
# unzip setuptools-36.2.7.zip
# cd setuptools-36.2.7
#python setup.py install
安装好后,就可以在返回第2步,直接安装pip
#python setup.py install
[root@localhost pip-1.5.4]# pip -V
pip 1.5.4 from /usr/lib/python2.6/site-packages/pip-1.5.4-py2.6.egg (python 2.6)
可以看到pip已经安装成功了
使用方法:
1) pip 查看已安装的软件
[root@localhost pip-1.5.4]# pip show --files python
---
Name: Python
Version: 2.6.6
Location: /usr/lib64/python2.6/lib-dynload
Requires:
Files:
Cannot locate installed-files.txt
2) pip查看帮助
[root@localhost pip-1.5.4]# pip --help
Usage:
pip <command> [options]
Commands:
install Install packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
search Search PyPI for packages.
wheel Build wheels from your requirements.
zip DEPRECATED. Zip individual packages.
unzip DEPRECATED. Unzip individual packages.
bundle DEPRECATED. Create pybundles.
help Show help for commands.
比如要安装redis
#pip install redis
安装就是这么easy,以上就是pip安装的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问可以留言交流.