一、国内镜像地址:
阿里云镜像
http://mirrors.aliyun.com/pypi/simple/
中国科技大学镜像
https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban)镜像
http://pypi.douban.com/simple/
清华大学镜像
https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学镜像
http://pypi.mirrors.ustc.edu.cn/simple/
华为云镜像
https://mirrors.huaweicloud.com/repository/pypi/simple/
二、使用方法
使用方法:
(1)安装某个包(以Python环境下pip安装yolov5为例)
pip install yolov5==7.0.13 -i https://pypi.tuna.tsinghua.edu.cn/simple/
//7.0.13为所需版本号,尾部url为对应镜像源地址
(2)安装整个requirements.txt
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
//requirements.txt中全是需要下载的依赖的列表,尾部url为对应镜像源地址
三、切换 pip
的默认镜像源
1.创建或修改pip配置文件,在终端(cmd)中执行以下命令来编辑pip配置文件:
(1)Linux/macOS
mkdir -p ~/.config/pip
nano ~/.config/pip/pip.conf
(2)Windows
需要修改 pip.ini
文件,路径通常是 C:\Users\你的用户名\AppData\Roaming\pip\pip.ini
。如果文件不存在,可以手动创建一个
2.修改配置文件:
在配置文件中添加或修改如下内容,指定你希望使用的镜像源(例如清华镜像):
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
3.保存并退出:
(1)在 nano
中编辑完后,按 Ctrl+O
保存,按 Ctrl+X
退出。
(2)在 Windows 上使用任何文本编辑器保存 pip.ini
文件。
之后就可以直接用刚设置的指定镜像源进行pip下载操作了。