pip换源

【一】介绍

"""
1、采用国内源,加速下载模块的速度
2、常用pip源:
	-- 豆瓣:https://pypi.douban.com/simple
	-- 阿里:https://mirrors.aliyun.com/pypi/simple
3、加速安装的命令:
	-- >: pip install -i https://pypi.douban.com/simple 模块名
"""

【1】镜像源

1. 清华大学镜像站:https://pypi.tuna.tsinghua.edu.cn/simple/
2. 阿里云镜像站:https://mirrors.aliyun.com/pypi/simple/
3. 中科大镜像站:https://pypi.mirrors.ustc.edu.cn/simple/
4. 中国科技大学镜像站:https://pypi.mirrors.ustc.edu.cn/simple/
5. 中国科学技术大学镜像站:https://pypi.mirrors.ustc.edu.cn/simple/
6. 华中科技大学镜像站:https://pypi.hustunique.com/

【二】永久配置安装源

【1】Windows

"""
1、文件管理器文件路径地址栏敲:%APPDATA% 回车,快速进入 C:\Users\电脑用户\AppData\Roaming 文件夹中
2、新建 pip 文件夹并在文件夹中新建 pip.ini 配置文件
3、新增 pip.ini 配置文件内容
"""

【2】MacOS、Linux

"""
1、在用户根目录下 ~ 下创建 .pip 隐藏文件夹,如果已经有了可以跳过
	-- mkdir ~/.pip
2、进入 .pip 隐藏文件夹并创建 pip.conf 配置文件
	-- cd ~/.pip && touch pip.conf
3、启动 Finder(访达) 按 cmd+shift+g 来的进入,输入 ~/.pip 回车进入
4、新增 pip.conf 配置文件内容
"""

【3】配置文件内容

"""
[global]
index-url = http://pypi.douban.com/simple
[install]
use-mirrors =true
mirrors =http://pypi.douban.com/simple/
trusted-host =pypi.douban.com
"""


'''
[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
'''

【三】查看当前配置的镜像源地址

  • 终端或cmd命令提示符中设置指定的镜像源地址:
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
  • 查看当前配置的镜像
pip config list
posted @ 2024-05-27 12:02  -半城烟雨  阅读(5)  评论(0编辑  收藏  举报