pip

1
2
3
4
5
6
pip install [package-name]              # 安装名为[package-name]的包
pip install [package-name]==X.X         # 安装名为[package-name]的包并指定版本X.X
pip install [package-name] --proxy=代理服务器IP:端口号         # 使用代理服务器安装
pip install [package-name] --upgrade    # 更新名为[package-name]的包
pip uninstall [package-name]            # 删除名为[package-name]的包
pip list                                # 列出当前环境下已安装的所有包

换源

临时
1
2
3
pip install $pkg -i $mirror
# 例
pip install django -i https://mirrors.aliyun.com/pypi/simple
永久
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
vim ~/.pip/pip.conf

[global]
# index-url = http://pypi.douban.com/simple
# index-url = https://pypi.tuna.tsinghua.edu.cn/simple
# index-url = https://pypi.mirrors.ustc.edu.cn/simple
index-url = https://mirrors.aliyun.com/pypi/simple

[install]
trusted-host = pypi.douban.com
trusted-host = pypi.tuna.tsinghua.edu.cn
trusted-host = pypi.mirrors.ustc.edu.cn
trusted-host = mirrors.aliyun.com