distribute是setuptools的取代(Setuptools包后期不再维护了),pip是easy_install的取代。
pip的安装需要setuptools 或者 distribute,如果你使用的是Python3.x那么就只能使用distribute因为Python3.x不支持setuptools。
这就简单的介绍一下Pip的安装与使用:
安装:
curl -O https://bootstrap.pypa.io/get-pip.py python get-pip.py使用方法:
pip install SomePackage pip search "query" pip install --upgrade SomePackage pip install --upgrade SomePackage==version补充:包安装后的py文件路径:/usr/local/lib/python2.7/dist-packages
pip类似RedHat里面的yum,安装Python包非常方便。本节详细介绍pip的安装、以及使用方法。
2.1 pip安装包
# pip install SomePackage [...] Successfully installed SomePackage 1 2 3 # pip install SomePackage [...] Successfully installed SomePackage2.2 pip查看已安装的包
# pip show --files SomePackage Name: SomePackage Version: 1.0 Location: /my/env/lib/pythonx.x/site-packages Files: ../somepackage/__init__.py [...] 1 2 3 4 5 6 7 # pip show --files SomePackage Name: SomePackage Version: 1.0 Location: /my/env/lib/pythonx.x/site-packages Files: ../somepackage/__init__.py [...]2.3 pip检查哪些包需要更新
# pip list --outdated SomePackage (Current: 1.0 Latest: 2.0) 1 2 # pip list --outdated SomePackage (Current: 1.0 Latest: 2.0)2.4 pip升级包
# pip install --upgrade SomePackage [...] Found existing installation: SomePackage 1.0 Uninstalling SomePackage: Successfully uninstalled SomePackage Running setup.py install for SomePackage Successfully installed SomePackage 1 2 3 4 5 6 7 # pip install --upgrade SomePackage [...] Found existing installation: SomePackage 1.0 Uninstalling SomePackage: Successfully uninstalled SomePackage Running setup.py install for SomePackage Successfully installed SomePackage2.5 pip卸载包
$ pip uninstall SomePackage Uninstalling SomePackage: /my/env/lib/pythonx.x/site-packages/somepackage Proceed (y/n)? y Successfully uninstalled SomePackage 1 2 3 4 5 $ pip uninstall SomePackage Uninstalling SomePackage: /my/env/lib/pythonx.x/site-packages/somepackage Proceed (y/n)? y Successfully uninstalled SomePackage3.1 安装redis
# pip install redis 1 # pip install redis3.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 1 2 3 4 5 6 # 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 redis3.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) 1 2 3 4 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.1 ImportError No module named setuptools 请参考《ImportError No module named setuptools解决》
安装使用一目了然,太简单了。
转载于:https://www.cnblogs.com/qiyebao/p/4818807.html