[PY爬坑] 修改PIP源为国内源

在通过pip install 命令安装第三方包的时候 会直接访问国外服务器 连接速度很慢 修改源后 速度会快很多 

推荐的国内pip源:

中国科学技术大学      http://pypi.mirrors.ustc.edu.cn/ 
 
阿里云               http://mirrors.aliyun.com/pypi/simple/  
 
清华大学             https://pypi.tuna.tsinghua.edu.cn/simple/

临时修改:在后边加个-i参数指定pip源,如下所示:

pip install package_name -i https://pypi.tuna.tsinghua.edu.cn/simple

永久修改:需要修改配置文件 

  • Windows:
  1. 进入%APPDATA%目录,例如C:\Users\gcstk\AppData\Roaming
  2. 新建pip文件夹,如果有则跳过
  3. 新建pip.ini文件,设置pip源,如下所示为清华大学的pip源
[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple/
timeout = 6000
 
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
 
disable-pip-version-check = true

最后

更改成功!

发布了8 篇原创文章 · 获赞 8 · 访问量 2665

猜你喜欢

转载自blog.csdn.net/qq_36142248/article/details/104199973