1. 简介
python在线安装库时会较慢,那是因为python的默认镜像源在国外,因此会慢;而国内有很多可以用的python镜像源,将python镜像源更改为国内的,则可以大大加快python库的安装速度。
2. python镜像源集合
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/ #推荐此源
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学 http://pypi.hustunique.com/simple/
山东理工大学 http://pypi.sdutlinux.org/simple/
加利福尼亚大学 https://www.lfd.uci.edu/~gohlke/pythonlibs/
3. python镜像源更换方法
1. 临时更换
可以在使用pip安装库的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
2. 永久更换
windows环境
在user目录中创建一个pip目录,如:C:\Users(用户)\xx\pip,新建文件pip.ini,内容如下[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
linux环境
在home目录下,修改 ~/.pip/pip.conf (如果没有自己创建一个), 内容如下:[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple
macos环境
在home目录下,修改 ~/.pip/pip.conf (如果没有自己创建一个), 内容如下:[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple
pycharm环境
参考博客:https://blog.csdn.net/IAMoldpan/article/details/78544598
版权声明:本文为myourdream2原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。