把经常用的几个功能总结下:
1 使用pip安装:(以simplejson为例)
直接安装: pip install simplejson
指定安装版本: pip install simplejson==3.0
可以直接使用本地的压缩包安装: pip install Django-1.5.1.tar.gz
使用别的源安装:pip install url_mirror package_name
如果安装时候还有其他的需求请使用 pip help install 查看
2 使用pip卸载 pip uninstall simplejson
3 列出操作系统path中python解释器安装的所有第三方packages
pip list
4 查找和显示包信息:
查找相关的包,查早Pypi库中有这个包吗?
1
2
3
4
5
6
7
8
9
10
11
12
|
(testenv) D:\installsofts\python>pip search simplejson
simplejson - Simple, fast, extensible JSON encoder
/decoder
for
Python
INSTALLED: 3.3.3 (latest)
exemelopy - exemelopy is a tool
for
building XML from native
Python data-types, similiar to the json
/simplejson
modules
omnijson - Wraps the best JSON installed, falling back on an
internal simplejson.
jsonutil - a wrapper around simplejson
which
deserializes
decimals to Decimal instead of to float
simple_json - Compatibility shim
for
simplejson
|
显示某个包的信息
1
2
3
4
5
6
7
8
|
(testenv) D:\installsofts\python>pip show django
(testenv) D:\installsofts\python>pip show simplejson
---
Name: simplejson
Version: 3.3.3
Location: i:\
test
\testenv\lib\site-packages
Requires:
|
注意这个命令指示显示本地安装的包的信息。
5 导出python解释器安装所有的包列表,方面其他环境安装相同的包。
1
|
(testenv) I:\test>pip freeze >requirment.txt
|
导出格式是键值对形式
以后安装的时候可以直接使用 pip install -r requirment.txt
6 有的时候win下使用pip不好使,可以使用easy_intall,因为easy_install 会自动找编译好的exe包。