1 Install Pip Self Package

1.1 Install

1
2
3
4
5
6
# Install with script
wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
python get-pip.py
# Install with package
apt-get install python-pip
yum install python-pip

1.2 Upgrade

1
pip install -U pip

2 Configure Source

源配置

2.1 Temporary

1
pip install package -i http://pypi.douban.com --trust-host=pypi.douban.com

2.2 Permanent

vim ~/.pip/pip.conf

1
2
3
4
5
6
7
8
9
[global]
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com
[install]
use-mirrors = true
mirrors = http://pypi.douban.com

# 不要添加,否则在安装virtualenv时会报错哦
install-option=--prefix=~/.local

3 Install package with Pip

3.1 Install

1
2
3
4
5
6
7
8
9
10
11
12
# 最新版本:
pip install package1
# 指定版本:
pip install package1==1.0.1
# 最小版本:
pip install package1>=1.0.1
# wheel包安裝:
pip install package1.whl
# 增加延時:
pip --default-timeout=100 install packages
# Reinstall:
pip install -I <package>

3.2 Uninstall

1
2
pip uninstall package1
pip uninstall package1 -r req.txt

3.3 Update

1
pip install -U packages

3.4 Information

1
2
3
4
5
6
7
8
# 列表
pip list --outdated
pip list -u
# information
pip show package1
# 某一个包所有可用版本
pip install yolk
yolk -V django
1
pip search *|wc -l

3.6 Requirement

1
2
3
4
# 生成
pip freeze > req.txt
# 如果發生異常,則所有包不能安裝成功
pip install -r req.txt

4 Setuptools and Easy_install

4.1 Setuptools

安装到指定目录:

1
2
设置PYTHONPATH:export PYTHONPATH=/root/test1/lib/python2.6/
安装:python setup.py install --prefix=/root/test1

4.2 easy_install

1
2
3
4
# Install
easy_install <package_name>
# Uninstall
sudo easy_install -m <package_name>