默认情况下 pip 使用的是国外的镜像,在下载的时候速度非常慢。
例如:Node中有一个Npm的工具,使用前需要配置中国镜像
同理:Python中有一个pip的工具,使用前需要配置中国镜像
Windows下,你需要在当前用户目录下(C:\Users\xx\pip,xx 表示当前使用的用户,比如张三)创建一个 pip.ini文件。
在pip.ini文件中输入以下内容:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
通过cmd可以查看用户名
测试是否设置成功:
pip config list 或者pip3 config list
其他国内镜像源
- 中国科学技术大学 : https://pypi.mirrors.ustc.edu.cn/simple
- 豆瓣:http://pypi.douban.com/simple/
- 阿里云:http://mirrors.aliyun.com/pypi/simple/