环境配置

修改镜像源

临时使用:

Linux Mac Windows 通用命令

可以在使用pip的时候在后面加上-i参数,指定pip源

1
pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple

永久修改:

Linux:

修改 pip.conf 文件 (没有就创建一个)

$HOME/.config/pip/pip.conf

修改内容如下:

1
2
3
[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple12

Mac:

修改 pip.conf 文件

$HOME/Library/Application Support/pip/pip.conf

如果没有上面的目录,在如下目录创建 pip.conf

$HOME/.config/pip/pip.conf

修改内容如下:

1
2
3
[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple12

Windows:

修改 pip.conf 文件 (没有就创建一个)

%APPDATA%\pip\pip.ini (%APPDATA%为用户目录)

修改内容如下:

1
2
3
[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

pip 10 以后版本可进行的设置

升级 pip 到最新的版本 (>=10.0.0) 后进行配置:

1
2
python -m pip install --upgrade pip
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple