wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate



[root@localhost ~]#tar -xvf pip-1.5.4.tar.gz
[root@localhost pip-1.5.4]#python setup.py install


1. pip使用详解

1.1 pip安装包



[root@localhost ~]# pip install Django
[root@localhost ~]# pip install MySQL-python


 1.2 pip查看已安装的包



[root@localhost ~]# pip list
MySQL-python (1.2.5) //MySQLDb
pip (1.5.4)
redis (2.10.5)
setuptools (23.1.0)
wsgiref (0.1.2)


1.3 pip检查哪些包需要更新



[root@localhost ~]# pip list --outdated
pip (Current: 1.5.4 Latest: 8.1.2)


1.4 pip升级包



[root@localhost ~]# pip install --upgrade redis
Requirement already up-to-date: redis in /usr/local/lib/python2.7/site-packages
Cleaning up...


1.5 pip卸载包



 


[root@localhost ~]#  pip uninstall redis 
Uninstalling redis:
/usr/local/lib/python2.7/site-packages/redis-2.10.5.dist-info/DESCRIPTION.rst
/usr/local/lib/python2.7/site-packages/redis-2.10.5.dist-info/METADATA
/usr/local/lib/python2.7/site-packages/redis-2.10.5.dist-info/RECORD
/usr/local/lib/python2.7/site-packages/redis-2.10.5.dist-info/WHEEL
/usr/local/lib/python2.7/site-packages/redis-2.10.5.dist-info/metadata.json
/usr/local/lib/python2.7/site-packages/redis-2.10.5.dist-info/top_level.txt
/usr/local/lib/python2.7/site-packages/redis/__init__.py
/usr/local/lib/python2.7/site-packages/redis/__init__.pyc
/usr/local/lib/python2.7/site-packages/redis/_compat.py
/usr/local/lib/python2.7/site-packages/redis/_compat.pyc
/usr/local/lib/python2.7/site-packages/redis/client.py
/usr/local/lib/python2.7/site-packages/redis/client.pyc
/usr/local/lib/python2.7/site-packages/redis/connection.py
/usr/local/lib/python2.7/site-packages/redis/connection.pyc
/usr/local/lib/python2.7/site-packages/redis/exceptions.py
/usr/local/lib/python2.7/site-packages/redis/exceptions.pyc
/usr/local/lib/python2.7/site-packages/redis/lock.py
/usr/local/lib/python2.7/site-packages/redis/lock.pyc
/usr/local/lib/python2.7/site-packages/redis/sentinel.py
/usr/local/lib/python2.7/site-packages/redis/sentinel.pyc
/usr/local/lib/python2.7/site-packages/redis/utils.py
/usr/local/lib/python2.7/site-packages/redis/utils.pyc
Proceed (y/n)? y
Successfully uninstalled redis


 


2. pip参数解释



[root@localhost ~]# 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.

General Options:
-h, --help Show help.
-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
-V, --version Show version and exit.
-q, --quiet Give less output.
--log-file <path> Path to a verbose non-appending log, that only logs failures. This log is active by default at
/root/.pip/pip.log.
--log <path> Path to a verbose appending log. This log is inactive by default.
--proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port.
--timeout <sec> Set the socket timeout (default 15 seconds).
--exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.
--cert <path> Path to alternate CA bundle.


 

 



[root@localhost lib.linux-x86_64-2.7]# python
Python 2.7.9 (default, Mar 20 2016, 17:45:53)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-55)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory


解决:



ln -s /usr/local/mysql56/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18

如果是64系统则:
ln -s /usr/local/mysql56/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18


  vi /etc/ld.so.conf    //加入libmysqlclient.so.18 所在的目录:/usr/local/mysql56/lib/

  加入: /usr/lib/

  保存退出后执行/sbin/ldconfig生效