pip安装和使用

pip用来管理和安装python包非常方便。怎么简单介绍下如何安装pip以及pip常用命令的使用

在线安装pip

#curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py

下载得到get-pip.py后,执行get-pip.py(前提是目标机器上已经安装了python)

#python get-pip.py

显示如下信息,表示安装成功

Downloading/unpacking pip
  Downloading pip-1.5.2-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded
Installing collected packages: pip
Successfully installed pip
Cleaning up.

其中,get-pip.py也可以从这个链接中下载:

pip常用命令

pip help

获取pip命令使用帮助。

pip install

用来安装python包,例如:

#pip install pymongo

#显示如下信息,表示安装成功

  Downloading/unpacking pymongo
  Downloading pymongo-2.6.3.tar.gz (324kB): 324kB downloaded
  Running setup.py (path:/tmp/pip_build_root/pymongo/setup.py) egg_info for package pymongo
    
Installing collected packages: pymongo
  Running setup.py install for pymongo
    building 'bson._cbson' extension
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ibson -I/usr/local/include/python2.7 -c bson/_cbsonmodule.c -o build/temp.linux-x86_64-2.7/bson/_cbsonmodule.o
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ibson -I/usr/local/include/python2.7 -c bson/time64.c -o build/temp.linux-x86_64-2.7/bson/time64.o
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ibson -I/usr/local/include/python2.7 -c bson/buffer.c -o build/temp.linux-x86_64-2.7/bson/buffer.o
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ibson -I/usr/local/include/python2.7 -c bson/encoding_helpers.c -o build/temp.linux-x86_64-2.7/bson/encoding_helpers.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/bson/_cbsonmodule.o build/temp.linux-x86_64-2.7/bson/time64.o build/temp.linux-x86_64-2.7/bson/buffer.o build/temp.linux-x86_64-2.7/bson/encoding_helpers.o -o build/lib.linux-x86_64-2.7/bson/_cbson.so
    building 'pymongo._cmessage' extension
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ibson -I/usr/local/include/python2.7 -c pymongo/_cmessagemodule.c -o build/temp.linux-x86_64-2.7/pymongo/_cmessagemodule.o
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ibson -I/usr/local/include/python2.7 -c bson/buffer.c -o build/temp.linux-x86_64-2.7/bson/buffer.o
    gcc -pthread -shared build/temp.linux-x86_64-2.7/pymongo/_cmessagemodule.o build/temp.linux-x86_64-2.7/bson/buffer.o -o build/lib.linux-x86_64-2.7/pymongo/_cmessage.so
    
Successfully installed pymongo
Cleaning up...

pip list

显示已经安装的python包

pip uninstall

卸载python包

pip install --upgrade

升级安装包

pip install --upgrade simplejson
Requirement already up-to-date: simplejson in /usr/local/lib/python2.7/site-packages
Cleaning up...

参考:

http://www.pip-installer.org/en/latest/index.html

你可能感兴趣的:(pip安装和使用)