python3 pip安装模块速度过慢导致失败
起因
今天用pip安装了一些模块,发现下载速度过慢,几KB的跑。于是乎google下解决方法。
https://blog.csdn.net/zywvvd/article/details/100607820
解决
通过国内的镜像,可以更快的下载。实测,中科大的非常快。
阿里云 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/
临时使用:
python3 -m pip install -i https://pypi.mirrors.ustc.edu.cn/simple/ -r requirements.txt
永久修改:
Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)
内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
Windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,然后新建文件pip.ini,即 %HOMEPATH%\pip\pip.ini,在pip.ini文件中输入以下内容(以豆瓣镜像为例):
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host = pypi.douban.com
创建pip.ini文件可以用文本编辑器,例如 sublime text3。
在这里插入图片描述
pip.ini文件中的内容如下:
在这里插入图片描述
最后在cmd尝试安装pandas,你会发现已经pip改用清华镜像了

浙公网安备 33010602011771号