1、為什么要pip換源下載
安裝第三方庫時,很多庫來自于國外,下載速度慢得感人!
2、常見的國內源
https://pypi.tuna.tsinghua.edu.cn/simple #清華
http://mirrors.aliyun.com/pypi/simple/ #阿里云
https://pypi.mirrors.ustc.edu.cn/simple/ #中國科技大學
http://pypi.hustunique.com/ #華中理工大學
http://pypi.sdutlinux.org/ #山東理工大學
http://pypi.douban.com/simple/ #豆瓣
3、換源方法
如果只是臨時使用,則可以臨時換源。
pip install -i 源地址(清華,阿里,豆瓣) 推薦使用使用清華源和阿里源
如果是個人PC機,建議永久換源。
##### Windows
-1 首先按下windows+e鍵,然后在文件地址欄輸入:%APPDATA% 回車,快速進入 C:\Users\電腦用戶\AppData\Roaming 文件夾中
-2 新建 pip 文件夾并
-3 在文件夾中新建 pip.ini 配置文件
-4 配置文件寫入:
如果想換源就直接把源的路徑換了就可以了
'''
[global]
index-url = https://mirrors.aliyun.com/pypi/simple
[install]
use-mirrors =true
mirrors =https://mirrors.aliyun.com/pypi/simple
trusted-host =mirrors.aliyun.com
'''# 以后再命令行中,下載模塊,就會走國內源了pip3.8 install django==3.2.12
如果想多添加幾個源,可以在pip.ini中配置以下信息。
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
extra-index-url =https://mirrors.aliyun.com/pypi/simple/https://mirror.baidu.com/pypi/simple