python中提高pip install速度
pip install命令默认是用的是python官方源,由于一些客观原因,连接速度很慢,甚至超时中断,到时很多模块安装不上,甚是苦恼!
怎么办?
使用国内镜像源,将以下命令完成拷贝出来,粘贴至记事本中,保存为bat文件,双击执行该批处理文件。
@echo off rem 声明采用UTF-8编码chcp 65001 echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* echo 自动设置pip安装配置文件 echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* set pipFolder=\\pip\\ if exist %userprofile%%pipFolder% ( echo 目录%userprofile%%pipFolder%已存在无需创建 ) else ( echo 创建%userprofile%%pipFolder% md %userprofile%%PiPFolder% ) cd %userprofile%%pipFolder% echo \[global\]>pip.ini ( echo timeout=60 echo index-url=http://pypi.douban.com/simple echo extra-index-url=https://pypi.tuna.tsinghua.edu.cn/simple/ echo \[install\] echo trusted-host=pypi.douban.com echo pypi.tuna.tsinghua.edu.cn echo timeout = 10 )>>pip.ini wmic ENVIRONMENT where "name='path' and username='<system>'" set VariableValue="%path%;%userprofile%%pipFolder%pip.ini"
然后再试试pip install命令,绝对飞一般的感觉。
另外给大家一些常用的pip国内源:
阿里云 https://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) https://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 https://pypi.mirrors.ustc.edu.cn/simple/
使用方法
临时生效
使用时加上参数 -i
如:
pip install matplotlib -i https://mirrors.aliyun.com/pypi/simple/
永久生效
1.Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)
内容如下:
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
2.windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini。内容同上。
相关文章
利用rest framework搭建Django API过程解析
这篇文章主要介绍了利用rest framework搭建Django API过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下2019-08-08VSCode安装Django插件后实现html语法提示的方法步骤
Vscode是微软推出的一款优秀的ide开发工具,界面简洁美观、默认支持中文,拥有丰富的插件,支持Windows,OS X和Linux,下面这篇文章主要给大家介绍了关于VSCode安装Django插件后实现html语法提示的方法步骤,需要的朋友可以参考下2022-08-08python库patchworklib多图表整合用法示例探究
这篇文章主要介绍了python库patchworklib对齐matplotlib图表,将多个图表的整合为单一图表用法示例探究,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2024-01-01
最新评论