当前位置: 首页 > 后端技术 > Python

Python快速进阶3——提高pipinstall的速度

时间:2023-03-26 02:03:12 Python

pipinstall命令默认使用官方python源。由于一些客观原因,连接速度很慢,甚至超时中断。很多模块当时都装不上,很苦恼。!该怎么办?使用国内镜像源,复制以下命令,粘贴到记事本中,另存为bat文件,双击执行批处理文件。@echooffrem语句采用UTF-8编码chcp65001echo\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*echo自动设置pip安装配置文件echo\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*setpipFolder=\\pip\\ifexist%userprofile%%pipFolder%(echodirectory%userprofile%%pipFolder%已经存在,无需创建)else(echocreate%userprofile%%pipFolder%md%userprofile%%PiPFolder%)cd%userprofile%%pipFolder%echo\[global\]>pip.ini(echotimeout=60echoindex-url=http://pypi.douban.com/simpleechoextra-index-url=https://pypi.tuna.tsinghua.edu.cn/simple/echo\[install\]echotrusted-host=pypi.douban.comechopypi.tuna.tsinghua.edu.cnechotimeout=10)>>pip.iniwmicENVIRONMENTwhere"name='path'andusername=''"setVariableValue="%path%;%userprofile%%pipFolder%pip.ini”然后试试pipinstall命令,感觉飞起来了。